Format Date from a Recordset

details212
details212 used Ask the Experts™
on
Hello All

I am trying to format the date returned from a recordset.  It's coming from microsoft access like this : 10/20/2009 11:52:02 PM

I am looking to write it out in the w3c standard.  The accepted date format that I need it in is:
2009-10-20
Year-Month(2 digit)-Dar(2 digit)

Thank you
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Commented:
here is your exact question from a few months ago:
http://www.experts-exchange.com/Database/Software/TeraData/Q_24229632.html
Expert of the Year 2008
Top Expert 2008

Commented:
>>I am trying to format the date returned from a recordset.  It's coming from microsoft access like this : 10/20/2009 11:52:02 PM
assuming the name of your field is purchasedOn, instead of executing:
SELECT purchasedOn FROM tableName

use:
SELECT FORMAT([purchasedOn],"yyyy-mm-dd") as [purchaseDate] FROM tableName

On your recordset:
rs.Fields("purchaseDate").value

will have the formatted date

Author

Commented:
Link to another Post

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial