Skip to main content
Participant
March 7, 2009
Question

Date Formatting

  • March 7, 2009
  • 1 reply
  • 254 views
Can anyone provide me with some guidance on inserting a record into a table, with a column for the current date/time? (e.g. the date/time the record is created). This is an ASP page, using DW CS3.

1) I create a variable to capture the current date/time:
var ContactUsDate = new Date();
Response.Write(ContactUsDate);

the response.write generates : Fri Mar 6 23:47:00 EST 2009


2) I'm using the 'record insert' functions, which generates the following code:

MM_editCmd.Parameters.Append(MM_editCmd.CreateParameter("param5", 135, 1, -1, (ContactUsDate))); // adDBTimeStamp

3) and I get the following error:

ADODB.Command error '800a0d5d'

Application uses a value of the wrong type for the current operation.

/ContactUs.asp, line 70


I've tried several variations on formatting the date, but to no avail. The only way I've been able to get it to work is to create a hidden form field, and hard code it's value (e.g. 03/06/2009). I want to have a date/time stamp to help with sorting on other pages within the site.

Thanks for any help!



This topic has been closed for replies.

1 reply

Inspiring
March 8, 2009
> Can anyone provide me with some guidance on inserting a record into a
> table,
> with a column for the current date/time? (e.g. the date/time the record is
> created). This is an ASP page, using DW CS3.
>

You don't need to do this with code - you can set the default for the field
in your database. Ie when a new record is inserted the Date field is
automatically populated. In SQL Server set the default value of your Date
field to GetDate(). In Access, speaking from memory, set it to Now() - or
Date() if you don't want the time as well.

Cheers,
Jon