473,395 Members | 1,905 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Time diff

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
Aug 20 '07 #1
7 3663

"magix" <ma***@asia.comwrote in message
news:46**********@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
Aug 21 '07 #2
David Morgan wrote on 21 aug 2007 in
microsoft.public.inetserver.asp.general:
>
"magix" <ma***@asia.comwrote in message
news:46**********@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)
Aug 21 '07 #3
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.
Aug 21 '07 #4
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:

<script type='text/vbscript'>
d = now
x = timevalue(d)
alert(x)
alert(year(x))
alert(month(x))
alert(day(x))
</script>

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Aug 21 '07 #5
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.
Aug 21 '07 #6

"Bob Barrows [MVP]" <re******@NOyahoo.SPAMcomwrote in message
news:u%****************@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.
Aug 23 '07 #7
Bookham Measures wrote:
"Bob Barrows [MVP]" <re******@NOyahoo.SPAMcomwrote in message
news:u%****************@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.
Aug 23 '07 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: NotGiven | last post by:
Below is a good elapsed time function I found. However, I'd like to return total seconds instead of broken down into days, hours, minutes & seconds. In other words, I want "125" instead of "2...
6
by: Stefan Behnel | last post by:
Hi! The logging module nicely prepends each line with a formatted date. However, I'm not interested in the actual date but only in the number of milliseconds that passed since the start of the...
2
by: Alberto Santini | last post by:
I ported a Jos Stam's demo about Fluid mech to check the difference of speed between C implementation and Python. I think I achieved good results with Python and there is space to improve, without...
9
by: Ching-Lung | last post by:
Hi all, I try to create a tool to check the delta (diff) of 2 binaries and create the delta binary. I use binary formatter (serialization) to create the delta binary. It works fine but the...
2
by: dhourd | last post by:
I'm performing a conversion of code from C to C# and I want to perform a callback to a function where the callback is performed at a certain time, like 2 March 2004 at 1:35pm. I realise there...
3
by: Richard | last post by:
Hi, Is there any way to get the time difference between Central(US) and GMT in vb.net. I'll appreciate your help/suggestion. Thanks RC
5
by: pedro.ballester | last post by:
Hi everyone, I am struggling with the following problem. I would like to measure the wall clock time required to run a section of the code with a precision of milliseconds. The attached code...
6
by: Jeremy Sanders | last post by:
Hi - I need to add support to a program for dates and times. The built-in Python library seems to be okay for many purposes, but what I would like would be Unix epoch style times (seconds relative...
9
by: Ron Adam | last post by:
I'm having some cross platform issues with timing loops. It seems time.time is better for some computers/platforms and time.clock others, but it's not always clear which, so I came up with the...
15
by: student4lifer | last post by:
Hello, I have 2 time fields dynamically generated in format "m/d/y H:m". Could someone show me a good function to calculate the time interval difference in minutes? I played with strtotime() but...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.