View Full Version : Date Format
Hi All,
how do I convert 6/9/2003 to 06/09/2003 in ASP
Abdul
Probably with
dim date2, date1
date2 = CDate(date1)
where date1 is the form without the 0 and date2 with the 0. But i fear ASP will then consider it as mm/dd/yyyy.
So this sort of stuf is safer
dim date2, date1
date2=CDate(CInt(day(date1)) + "/" + CInt(month(date1)) + "/" + CInt(year(date1)))
(can be used without the CDate)
Hi raf,
the first option return Date in the m/d/yyyy format while the second option that is;
dim date2, date1 date2=CDate(CInt(day(date1)) + "/" + CInt(month(date1)) + "/" + CInt(year(date1)))
return this ERROR Message;
Error Type:
Microsoft VBScript runtime (0x800A000D)
Type mismatch: '[string: "/"]'
Thanks
Abd
Hmm. Try
dim date2, date1
date2=day(date1)) & "/" & month(date1)) & "/" & year(date1)
date2=CDate(date2)
i don't know. Never had anything like that. How did you get the original value?
original value,.......... do you mean date1
I used
<%
date1 = date()
%>
yeah raf,
came out but in this form 9/6/2003 ,
what I want is 09/06/2003, I want (0) before day and month.
Abd
I see what you want, but you should start from the date. Like
date2=day(date()) & "/" & month(date()) & "/" & year(date())
i used that and it always worked. If you just want to display the date in the dd/mm/yyyy format of your regional settings, then use
session.LCID =your landcode ID
petertran123
06-17-2003, 03:23 PM
i have a date format 06121974 how do i convert it into 06/12/1974. Can someone help me with this thanks
dim value, datevalue
value="06121974" 'or CStr(yournumericalvariable)
datevalue = CDate(Left(value,2) & "/" & Mid(value,3,2) & "/" & Right(value,4))
maybe for safety
dim value, datevalue
value="06121974" 'or CStr(yournumericalvariable)
if Len(value) = 8 then
datevalue = CDate(Left(value,2) & "/" & Mid(value,3,2) & "/" & Right(value,4))
else
response.write("Problem")
end if
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.