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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to convert datetime to string in VBscript

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
Hello, i'm really new to VBScript...

How can i convert a datetime ODBC (access, mdb) field to a string variable ?

I have not found yet a way...


Thanx in advance

Demy Mortelliti
 
Are you wanting to do this on your select statement from the database, or are you willing to convert after the select is performed, and on a row-by-row basis? Using VBScript, you can simply do a "strMyDate = CStr(theDateVariable)" to retrieve the string value / representation of "theDateVariable" into "strMyDate". You could also do a CStr() on the "FormatDateTime(theDateVariable)" function to change the actual format of the date before taking the string value of it.

If you want to do this in the select statement, however, you'll have to put a conversion-type of formula into your select statement. I don't know what formula to use, offhand, but if you were using SQL Server, you could use a convert/cast function on that column. (SELECT Cast(DateColumn, Parameters) AS StringDateColumn FROM TableName), just as a very vague example.

If you're using MS Access, see this link:
It *may* be able to help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top