Last post Apr 05, 2011 12:57 PM by bbcompent1
Apr 05, 2011 07:12 AM|PJLaurenson|LINK
I am currently using now() in my sql insert statement to my access 2007 database but for the
date 05/04/2011 it is putting it as 5/04/2011 8:44:54 PM instead of 05/04/2011 20:44:54. I know I can use:
<%= DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss")%> but am not sure how to get the same result within the sql statement.
Any suggestions? :-) Thanks
InsertCommand="INSERT INTO [Table] ([Column1], [Column2], [Column3], [Column4], [Column5], [Column6], [Column7], [Column8], [Column9]) VALUES (?, ?, ?, ?, ?, ?, ?, ?, Now())"
Apr 05, 2011 07:34 AM|bbcompent1|LINK
Right off by that time difference, that tells me your server is about 12 hours ahead of you. Remember that the date and time is determined by what's on the server, not where you are. What you can do is subtract 8 hours using this query to change the time
For your reading pleasure, here is some more stuff to check out with relation to dates and times
Apr 05, 2011 08:27 AM|PJLaurenson|LINK
The server time is the correct local time. This is for a locally hosted application for internal use so will only ever have people from my timezone using it. This is more for record keeping purposes and has been requested by the head of department to prevent
misuse by users.
I'm just trying to get the date format that is inserted into the database to be in the format of
05/04/2011 20:10:00 instead of 5/04/2011 8:10:00 PM. I don't need to change the timezone, just the time format.
Apr 05, 2011 10:08 AM|hans_v|LINK
I'm just trying to get the date format that is inserted into the database
Dates are not stored in a format (not in Access, nor in any other database). A date is a date, it's up to you in the UI to use the format you want to display...
Apr 05, 2011 12:57 PM|bbcompent1|LINK
Oh, ok now I get it, to display 24 hour format, simply do this "MM-dd-yyyy HH:mm:ss" the HH is 24 hour, hh would format as 12 hour. So using your example:
<%= DateTime.Now.ToString("dd/MM/yyyy hh:mm:ss tt")%>
That tt is am/pm