Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
0

Date Formatting

New Here ,
Mar 06, 2009 Mar 06, 2009

Copy link to clipboard

Copied

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!



TOPICS
Server side applications

Views

236
Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 08, 2009 Mar 08, 2009

Copy link to clipboard

Copied

LATEST
> 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


Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines