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

Inserting Date Time Into SQL...Help

Status
Not open for further replies.

jay24k

MIS
May 12, 2004
32
US
I'm trying to insert the current date into an SQL database. I have tried the database field set to datetime and smalldatetime. I have tried using the commands date() and also building the date manually by grabbing month..etc.

What is the easiest way to input a date into a datetime field? I've looked everywhere and I can't believe this to be so much of a pain. I'd rather not leave it as a VAR or numeric field.

Thanks!
 
Have you tried getdate() ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
I've tried that but I get a type mismatch on that line.
 
I was trying to have it imported from the form but I set the default value in the SQL field to getdate(). I thought you could use that in the actual ASP page.

I would still like to know how to pass a datetime format to a SQL database correctly with the SQL set as datetime or smalldatetime.

Thanks again.
 
Something like this, I presume:
'yyyy-mm-dd hh:nn:ss'

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top