Hi

I need to compare 2 date and time values each one in this format #27-
Jan-2008.21:00#
Now I want to use the datediff to compare them but first I need to
change the format

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 ?

Re: Compare date and time by McKirahan

McKirahan
Mon Jan 28 10:56:36 CST 2008

"EF" <felad@walla.com> wrote in message
news:c4a0fc54-288b-4617-b4eb-9e751c316884@v29g2000hsf.googlegroups.com...
> Hi
>
> I need to compare 2 date and time values each one in this format #27-
> Jan-2008.21:00#
> Now I want to use the datediff to compare them but first I need to
> change the format
>
> 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 ?

This works:

WScript.Echo DateDiff("m",#27-Jan-2008 21:00#,Now) & " minutes"

Just remove the period separating the date and time.



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)

Re: Compare date and time by McKirahan

McKirahan
Mon Jan 28 10:59:00 CST 2008

"McKirahan" <News@McKirahan.com> wrote in message
news:JOqdneZJGODZlAPanZ2dnUVZ_gOdnZ2d@comcast.com...
> "EF" <felad@walla.com> wrote in message
> news:c4a0fc54-288b-4617-b4eb-9e751c316884@v29g2000hsf.googlegroups.com...
> > Hi
> >
> > I need to compare 2 date and time values each one in this format #27-
> > Jan-2008.21:00#
> > Now I want to use the datediff to compare them but first I need to
> > change the format
> >
> > 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 ?
>
> This works:
>
> WScript.Echo DateDiff("m",#27-Jan-2008 21:00#,Now) & " minutes"
>
> Just remove the period separating the date and time.


Oops, "n" is minutes:

WScript.Echo DateDiff("n",#27-Jan-2008 21:00#,Now) & " minutes"