Is there anyway to store a date/time stamp in a DB

Results 1 to 6 of 6

Thread: Is there anyway to store a date/time stamp in a DB

  1. #1
    Join Date
    Dec 1969
    Posts
    294

    Default Is there anyway to store a date/time stamp in a DB

    I am trying to store a date/time stamp in one field in an Access database. I keep receiving an error in my VBScript ASP page specifically in the Insert Into statement referring to the datetime stamp.<BR><BR>My code is just<BR><BR>mySQL = "insert into TableName(DateTimeStamp) values(#" Now "#)"<BR><BR>What am I doing wrong?<BR><BR>TIA<BR>

  2. #2
    Cable Guest

    Default RE: Is there anyway to store a date/time stamp in

    Are you using SQL Server or Access?

  3. #3
    Hugo Mejia Guest

    Default RE: Is there anyway to store a date/time stamp in

    Redefine your statement to<BR><BR>mySQL = "insert into TableName(DateTimeStamp) values(#" & Now & "#)"<BR><BR>Notice the ampersand (&) on both ends of the Now function. This will work for an Access database. For SQL server, use single quotation marks around Now (as opposed to ampersands).<BR>You also need to make sure the data type of the &#039DateTimeStamp&#039 field is DateTime.<BR>

  4. #4
    Cable Guest

    Default RE: Is there anyway to store a date/time stamp in

    For SQL Server it is best to use CURRENT_TIMESTAMP if your SQL Server is over version 4.X, unless you want to keep compatability with older SQL Servers or Sybase. <BR><BR>Exp:<BR><BR>mySQL = "insert into TableName(DateTimeStamp) values(CURRENT_TIMESTAMP)"<BR><BR>If it is SQL Server 4.X or Sybase use:<BR><BR>mySQL = "insert into TableName(DateTimeStamp) values(GetDate())"<BR><BR>Unless you want the ASP page to parse in the timestamp.


  5. #5
    Join Date
    Dec 1969
    Posts
    294

    Default RE: Is there anyway to store a date/time stamp in

    I&#039m sorry for the ambiguity.<BR><BR>The DB is an Access Datatbase. This is script that will be in an ASP page. I will use this SQL<BR><BR>mySQL = "insert into TableName(DateTimeStamp) values(#" & Now & "#)<BR><BR>in a recordset object in the page. I&#039m also sorry again because I do have the ampersands in the SQL statement. I was just retyping it for the forum and left the ampersands out.<BR><BR>I still receive an error in my insert into statement. I found something that might help but I wasn&#039t sure. It says to format the date like this #Date# #Time# inside the SQL. <BR><BR>I don&#039t know what I am doing wrong, but something is still wrong.<BR>Thanks for all your help<BR>

  6. #6
    Join Date
    Dec 1969
    Posts
    294

    Default RE: Is there anyway to store a SOLVED

    I found a Q article on the M$ support. Apparently my table name was a reserved word. If I put brackets [] around it it would work or I just changed the name.<BR>Thanks for your help<BR>Stephen

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •