Time diff

Time diff

am 20.08.2007 18:15:58 von magix

Dear Guru,

If I want to compare time, what is the best approach to go ? Any good
example ? DateDiff ( ) ?

Pseudocode
========

submitdate = rs.fields("submissiondate") -> submissiondate is a date field
in a table.

if time for submitdate < = 8:15am then
do something A
elseif time for submitdate <= 10:15am then
do something B
elseif time for submitdate <= 12:15pm then
do something C
else
do something D


thank you very much !

Magix

Re: Time diff

am 21.08.2007 21:27:33 von David Morgan

"magix" wrote in message
news:46c9be3e$1_2@news.tm.net.my...
> Dear Guru,
>
> If I want to compare time, what is the best approach to go ? Any good
> example ? DateDiff ( ) ?
>
> Pseudocode
> ========
>
> submitdate = rs.fields("submissiondate") -> submissiondate is a date
> field in a table.
>
> if time for submitdate < = 8:15am then
> do something A
> elseif time for submitdate <= 10:15am then
> do something B
> elseif time for submitdate <= 12:15pm then
> do something C
> else
> do something D
>
>
> thank you very much !
>
> Magix
>

If submitdate < #08:16:00# Then
DoA
ElseIf submitdate < #10:16:00# Then
DoB
Else
DoD
End If

Re: Time diff

am 21.08.2007 21:40:42 von exjxw.hannivoort

David Morgan wrote on 21 aug 2007 in
microsoft.public.inetserver.asp.general:

>
> "magix" wrote in message
> news:46c9be3e$1_2@news.tm.net.my...
>> Dear Guru,
>>
>> If I want to compare time, what is the best approach to go ? Any good
>> example ? DateDiff ( ) ?
>>
>> Pseudocode
>> ========
>>
>> submitdate = rs.fields("submissiondate") -> submissiondate is a date
>> field in a table.
>>
>> if time for submitdate < = 8:15am then
>> do something A
>> elseif time for submitdate <= 10:15am then
>> do something B
>> elseif time for submitdate <= 12:15pm then
>> do something C
>> else
>> do something D
>>
>>
>> thank you very much !
>>
>> Magix
>>
>
> If submitdate < #08:16:00# Then
> DoA
> ElseIf submitdate < #10:16:00# Then
> DoB
> Else
> DoD
> End If

This will only work if submitdate is also a time and not a date-time.

Try this to see what I mean:

<% = year(#08:16:00#) %>


--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)

Re: Time diff

am 21.08.2007 21:50:05 von reb01501

magix wrote:
> Dear Guru,
>
> If I want to compare time, what is the best approach to go ? Any good
> example ? DateDiff ( ) ?
>
> Pseudocode
> ========
>
> submitdate = rs.fields("submissiondate") -> submissiondate is a date
> field in a table.
>
> if time for submitdate < = 8:15am then
> do something A
> elseif time for submitdate <= 10:15am then
> do something B
> elseif time for submitdate <= 12:15pm then
> do something C
> else
> do something D
>
>
You need to extract the time component from the datetime value being
retrieved from the database. One way to do that is to realize that
vbscript uses a Double to store the datetime, with the time of day
stored in the decimal portion. So, you would do this:

dim decimaldatetime
decimaldatetime = cdbl(submitdate)
dim submittime
submittime = cdate(decimaldatetime - int(decimaldatetime))

if submittime <= #08:15# then
elseif submittime <= #10:15# then
elseif submittime <= #12:15# then
else
end if

--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.

Re: Time diff

am 21.08.2007 23:08:34 von exjxw.hannivoort

Bob Barrows [MVP] wrote on 21 aug 2007 in
microsoft.public.inetserver.asp.general:

> ou need to extract the time component from the datetime value being
> retrieved from the database. One way to do that is to realize that
> vbscript uses a Double to store the datetime, with the time of day
> stored in the decimal portion. So, you would do this:
>
> dim decimaldatetime
> decimaldatetime = cdbl(submitdate)
> dim submittime
> submittime = cdate(decimaldatetime - int(decimaldatetime))

submittime = timevalue(submitdate)

> if submittime <= #08:15# then
> elseif submittime <= #10:15# then
> elseif submittime <= #12:15# then
> else
> end if

==========================

In fact, all time only values are really dated on 1899/12/30.

Try:



--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)

Re: Time diff

am 21.08.2007 23:18:54 von reb01501

Evertjan. wrote:
> submittime = timevalue(submitdate)
>
!
Never saw that one!
And of course, there's a DateValue function I've never used!

--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.

Re: Time diff

am 23.08.2007 18:00:32 von Bookham Measures

"Bob Barrows [MVP]" wrote in message
news:u%23KKijD5HHA.5724@TK2MSFTNGP05.phx.gbl...
> Evertjan. wrote:
>> submittime = timevalue(submitdate)
>>
> !
> Never saw that one!
> And of course, there's a DateValue function I've never used!
>
> --
> Microsoft MVP -- ASP/ASP.NET
> Please reply to the newsgroup. The email account listed in my From
> header is my spam trap, so I don't check it very often. You will get a
> quicker response by posting to the newsgroup.
>
>

Although you'd want TimeValue.

The 1899 date is always how SQL stores time only values. Presume it is
significant from an integer point of view.

Re: Time diff

am 23.08.2007 18:43:10 von reb01501

Bookham Measures wrote:
> "Bob Barrows [MVP]" wrote in message
> news:u%23KKijD5HHA.5724@TK2MSFTNGP05.phx.gbl...
>> Evertjan. wrote:
>>> submittime = timevalue(submitdate)
>>>
>> !
>> Never saw that one!
>> And of course, there's a DateValue function I've never used!
>
> Although you'd want TimeValue.
Huh?
Oh, I see. No, I was only pointing out the existance of DateVale, not
suggesting its use in this situation.
>
> The 1899 date is always how SQL stores time only values.
:-)
Why is what "SQL" does relevant? We are discussing only vbscript
variables and functions here. How SQL stores datetimes is irrelevant.
:-)
Also, the seed date used does vary depending on the database being used.
For example, I believe Jet uses 1/1/1900 - I may be wrong, and I don't
have time to go check it, but I do know it's a different seed date than
what SQL Server uses.

--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.