BigJobbies
BigJobbies

Reputation: 4045

ASP / SQL - Dates being echoed different to what the database

I have a simple sql script in my classic ASP which is as follows

sql = "SELECT date FROM sales WHERE userid=1"
Set RS = Conn.Execute(sql)

date = RS.Fields("date")

Response.Write date

This is a broken down version, it works, but the results are different.

Im looking at the database using SQL Server and it is showing me

2014-10-05 15:06:00

But when the Response.Write runs, it is displaying it as

10/5/2014 3:06:00 PM

How can i use Response.Write to display it exactly as it is in the database?

Cheers,

Upvotes: 1

Views: 48

Answers (1)

Iłya Bursov
Iłya Bursov

Reputation: 24146

use

sql = "SELECT CONVERT(VARCHAR(19), date, 120) as date FROM sales WHERE userid=1"

Upvotes: 1

Related Questions