ODBC DateTime format in ASP (VBScript)

Status
Not open for further replies.
A co-worker and I, both new to VBScript and ASP in general, are trying to insert the current datetime into an MS-SQL database table. Is there a function in VBScript (or SQL for that matter) to format a datetime object to an ODBC compatible datetime?

I am familiar with ColdFusion and it has a function called ODBCDateTimeFormat just for this sort of thing. In all my searching through a Wrox Press ASP book and all the VBScript reference material I could find on MSDN, I couldn't find any function to do this in VBScript.

I just got the idea that maybe you could do it straight through the SQL statement, but I haven't found a good reference to look through for that idea yet.

Anyone know? I'm to the point of babbling.
 
a SQL field of type timestamp(14) will automatically be filled with an integer of the form: YYYYMMDDHHMMSS such as 20020425191500 would be right around now (EST).

On insertion, it is given the value NULL and SQL automagically fills in the correct timestamp. On modification, the timestamp is automagically updated, save it is not explicity specified in the modification query.

Dunno if this helps you, but it might work out.
 
I'll test these out when I get back to work tomorrow. We had formatted a string that looked like {ts 25-4-2002 6:02:58} (as an example) and SQL was barfing on the 4. It wanted 04. and when we fixed that, it barfed on the 6. It wanted 06. Highly annoying. So we have something working currently but it is massively ugly.

I'll have to see what the field type is for our dB. It's part of a prepackaged "solution" so I don't know how much we can alter. We are inputting a bunch of data based on a form from a webpage. I'll let you know how it goes tomorrow.

Thanks.
 
Status
Not open for further replies.