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!

MSSQL 2000 Datetime question (Newbie) 1

Status
Not open for further replies.

ants211

Technical User
Feb 22, 2002
15
GB
Hi, I am trying to input a date from an ASP form to my SQL 2000 database. The date I put in is <% =now %> from my ASP page which gives the date in MM/DD/YYYY HH:MM:SS for example - 3/11/2003 11:33:18 AM. When I try to insert this value into a DateTime field in my DB, nothing gets inserted. I need the date/time values to be in DateTime format so I can perform calculations on the data later on. Should I be entering the date and time in a different format or should I insert this data into a different field type in my SQL 2000 database? Any help would be appreciated!
 
I don't know if this is the same as what is happening to you but we always put &quot;set dateformat dmy&quot; in front of our sql statements - maybe if you set your dateformat the way you want it prior to doing the insert it might be OK...
 
Rather than pass the current date from the ASP page, use getdate() in your SQL statement. This avoids any problems with date formats. --James
 
Like James, I prefer to use the SQL Server datetime function. However, there are occasions when you need to use the client datetime. Make sure you enclose the datetime value in single quotes before sending it to SQL Server. If you want to get the best answer for your question read faq183-874 and faq183-3179.
Terry L. Broadbent - DBA
SQL Server Page:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top