//  home   //  advanced search   //  news   //  categories   //  sql build chart   //  downloads   //  statistics
 ASP FAQ 
Home
ASP FAQ Tutorials

   8000XXXX Errors
   Alerts
   ASP.NET 2.0
   Classic ASP 1.0
      COM / ActiveX Components
      Forms
      General Topics
      Date/Time Routines
      Email Scripts & Info
      Files/Directories & FSO
   Databases
   General Concepts
   Search Engine Optimization (SEO)

Contact Us
Site Map

Search

Web
aspfaq.com
tutorials.aspfaq.com
classicasp.aspfaq.com

ASP FAQ Tutorials :: Classic ASP 1.0 :: Date/Time Routines :: Why do I have problems inserting NOW() into a database?


Why do I have problems inserting NOW() into a database?

Several hiccups can happen when trying to INSERT or UPDATE a record with the current date and time. For one, regional settings and/or SQL Server's dateformat setting can throw you for a loop (see Article #2260 for some workarounds to regional settings issues), and even delimiters can get in the way when moving between platforms (see Article #2023). 
 
My suggestion: let the database put the date and time on the record. In SQL Server, you can do this: 
 
CREATE TABLE blah 

    foo VARCHAR(5), 
    bar DATETIME NOT NULL DEFAULT GETDATE() 
)
 
(And for UPDATEs, you could create a trigger.) 
 
This way, you don't have to worry about your application code getting the date format correct (since SQL Server will automatically generate the current time for you, and store it in its own internal format), and you can have one less column in your INSERT list.

Related Articles

Can I get millisecond accuracy in ASP?
Can I make VBScript format dates for me?
Could I get a little help with dates?
Given a date, how do I find the beginning and end of that week?
Given two dates, how do I determine an age?
How do I calculate dates, such as the first day of the month?
How do I convert a DATEDIFF to days, hours, and minutes?
How do I convert a timespan, in seconds, to HH:MM:SS?
How do I convert local time to UTC (GMT) time?
How do I count the number of business days between two dates?
How do I delimit/format dates for database entry?
How do I determine the number of seconds since 1/1/1970?
How do I display time in military format?
How do I implement a calendar / datepicker in ASP?
How do I select time only from a DATETIME column?
Why does JavaScript's document.lastModified() not work in ASP files?

 

 


Created: 8/10/2002 | Last Updated: 8/10/2002 | broken links | helpful | not helpful | statistics
© Copyright 2006, UBR, Inc. All Rights Reserved. (367)

 

Copyright 1999-2006, All rights reserved.
Finding content
Finding content.  An error has occured...