Forum Moderators: open
Does anyone know why?
Thanks
fintan.
<%
Session.LCID = 2057
EuDate = FormatDateTime(Date,vbShortDate)
Response.Write(EuDate)
%>
This returns the proper date from the server. Some things up with the insert/update behaviour. I wouldn't mind but I had this fixed, or so I thought. It only happens with numbers 1-12. I update say a date 04/02/2002, first try it goes in right but if I update the record the second time "without modifing any details" it becomes 02/04/2002.
Any ideas?
dd-mmm-yyyy i.e 31-jan-2003
The year and day cant switch if you use 4 digits for year, the day and month cant switch if you use letters instead of numbers for month.
Get the mmm by using left(monthname(intMonth),3)
<%
'Function to format date string
Function format_date(date,dataformat)
months =Array("January","February","March","April","May","June","July","August","September","October","November","December")
mon = Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec")
'dd-MMM-yyyy = 0
'MM/dd/yyyy = 1
'dd MMMM,yyyy = 2
'MMMM dd,yyyy = 3
daypart = Day(date)
monthpart = Month(date)
yearpart = Year(date)
monthpart = monthpart -1
if(dataformat = 0) then
format_date = daypart & "-" & mon(monthpart) & "-" & yearpart
end if
if(dataformat = 1) then
format_date = monthpart & "-" & daypart & "-" & yearpart
end if
if(dataformat = 2) then
format_date = daypart & " " & months(monthpart) & " " & yearpart
end if
if(dataformat = 3) then
format_date = months(monthpart) & " " & daypart & "," & yearpart
end if
end Function
Function L_HTMLEncode(stringToEncode)
if IsNull(stringToEncode) OR IsEmpty(stringToEncode) then
L_HTMLEncode = stringToEncode
else
L_HTMLEncode = Server.HTMLEncode(stringToEncode)
end if
end Function
%>
So searching for a record with today's date can cause problems if you are on the this side of the pond.
The solution I came up with which seems to work is to force the date thus:-
"#" & Month(Date) & "/" & Day(Date) & "/" & Year(Date) & "#;"
so,
strSQL = "Select * from Table WHERE Datefield = #" & Month(Date) & "/" & Day(Date) & "/" & Year(Date) & "#;"
now works.
What I did then was to set a string at the start of the page like
strToday = Month(Date) & "/" & Day(Date) & "/" & Year(Date)
so whenever I needed to refer to today's date I inserted the string instead, thus:-
strSQL = "SELECT * from Table WHERE DateField = #" & strToday & "#;"
Try that fintan and see if it works for you.
Onya
Woz