inserting date created with new record
am 24.04.2008 18:24:03 von dean.h.brownI'm trying to set the date created when I add a new record: (using a
FormView)
This works:
%>"
InsertCommand="INSERT INTO [AdultEvent] ([DateCreated],
[DateLastModified], [EventName])
VALUES ('04/23/2008', '04/23/2008', @EventName)"
but I want the dates to be the current date and time.
I've tried variations on this:
VALUES ('<%$ DateTime.Now.ToString('MM/dd/yyyy') %>', '04/23/2008',
@EventName)"
But I get:
System.Data.SqlClient.SqlException: Incorrect syntax near 'MM'.
Or:
VALUES ('<%$ DateTime.Now %>', '04/23/2008', @EventName)"
System.Data.SqlClient.SqlException: Conversion failed when converting
datetime from character string