Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Easy SQL Date Format Question

Status
Not open for further replies.

hm1sal

MIS
May 30, 2002
6
US
Greetings,

I have a datalist field that gets its data from this SQL statement in the Dataenvironment command:

SELECT TDate FROM tblTable ORDER BY TDate

All works well, the entries are sorted in date order. I just want entires like 1/22/2004 to show as 01/22/2004 simply so it looks better.

I have tried and failed with many different ways. Please forgive my lack of SQL/VB skills.

Thanks in advance

-jsalvin

 
You can format the dates in VB using the Format() function. Here is an example:

Format(Now(), "yyyy-mm-dd")

So when you read date out of the ADO recordset, the code might be:

strDate = Format(rdData("TDate").Value, "yyyy-mm-dd")

The other option is to format the date in the database but the result will come back as a String datatype instead of a Date datatype.

Here is an example:

SELECT 'TDate' = CONVERT(char(10), TDate, 126) FROM tblTable ORDER BY TDate

I would format the date in VB instead of the database.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top