View Full Version : Date Question
Thatguy2001au
10-24-2002, 11:38 AM
This might sound silly, but i can't remember how to change the format of the date using asp
I have the code
date()
in one of my asp pages which i send to a database but the default format is 'mm,dd,yyyy'.
How can i change it do it is
'dd,mm,yyyy'???
Thanks
you can change that by specifying the Land Code ID in your asp file.
like this:
<%
session.lcid=2067
%>
this would change the formats to Belgian (Dutch). It also changes the decimal point into a comma etc.
at least, for displaying on screen. Don't know about saving to db.
i just don't specify a format for my date-variables and Access then automatically takes the setting as specified in your control panel. (i do specify a type, buth not a format)ASP automatically converts them into the (american) standardformat, unless you specify the LCID.
i never pay much attention to how it is saved. If i want to display it in dd/mm/yyyy format, i use the LCID, buth for storing in the db, i don't mind the format to much.
rcreyes
10-24-2002, 02:51 PM
You can try manipulating the date value before saving it to a database, for example:
if the date is 7/4/2002
dDate="7/4/2002"
dtMonth = Right("00" & Mid(dDate,1, Instr(dDate, "/")-1),2)
dtDay = Right ("00" & Mid(dDate, Instr(dDate, "/") + 1, InstrRev(dDate, "/") - (Instr(dDate, "/") + 1)), 2)
dtYear = Mid(dDate, InstrRev(dDate, "/") + 1)
'-- then you can put it back together in any order, in your case dd,mm,yyyy
newDt = dtDay & "," & dtMonth & "," & dtYear
the Right function is use to pad the value with leading zero for the month and day
hope this help...
Thanks,
Ray
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.