Re: Compare date and time by Evertjan
Evertjan
Mon Jan 28 10:56:59 CST 2008
EF wrote on 28 jan 2008 in microsoft.public.scripting.vbscript:
> I need to compare 2 date and time values each one in this format #27-
> Jan-2008.21:00#
That is not a format, that is a mistake. ;-)
#..# is not a string it is a litteral and your example is illegal.
A format is a string, a way to output a value [since Fortran].
Use:
dateTime = #2008/01/27 21:00#
And the ASP-VBS engine will understand what is ment.
> Now I want to use the datediff to compare them but first I need to
> change the format
s1 = "#27-Jan-2008.21:00#"
s1 = replace(s1,"#","")
s1 = replace(s1,"."," ")
s1 = cdate(s1)
s2 = "#29-Jan-2008.22:00#"
s2 = replace(s2,"#","")
s2 = replace(s2,"."," ")
s2 = cdate(s2)
response.write datediff("h",s1,s2) ' shows: 49
> I successfully used the cdate function to change the format of the
> date and the time but not when they are together
>
> Any suggestions on how can I compare them ?
Next time read the specs first, I suggest to you.
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)