473,796 Members | 2,690 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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("subm issiondate") -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 3687

"magix" <ma***@asia.com wrote 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("subm issiondate") -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.publi c.inetserver.as p.general:
>
"magix" <ma***@asia.com wrote 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("subm issiondate") -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("subm issiondate") -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(decimalda tetime - int(decimaldate time))

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.publi c.inetserver.as p.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(decimalda tetime - int(decimaldate time))
submittime = timevalue(submi tdate)
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(submi tdate)
!
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******@NOyah oo.SPAMcomwrote in message
news:u%******** ********@TK2MSF TNGP05.phx.gbl. ..
Evertjan. wrote:
>submittime = timevalue(submi tdate)
!
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******@NOyah oo.SPAMcomwrote in message
news:u%******** ********@TK2MSF TNGP05.phx.gbl. ..
>Evertjan. wrote:
>>submittime = timevalue(submi tdate)
!
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
12346
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 minutes 5 seconds". Any ideas? Thanks very much! function calcElapsedTime($time) { // calculate elapsed time (in seconds!) $diff = time()-$time;
6
4675
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 program. What is the best way of doing that? Thanks, Stefan
2
3709
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 to extend the program with C routine, I mean. -- Good hack, Alberto Santini (http://www.albertosantini.it/)
9
6520
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 delta binary is pretty huge in size. I have 1 byte file and 2 bytes file, the delta should be 1 byte but somehow it turns out to be 249 bytes using binary formatter. I guess serialization has some other things added to the delta file.
2
15269
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 are loads of timers in C#, but they all perform repeatable events using an elapsed time which is not what I desire. The C code uses the functions
3
14892
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
4944
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 does the job on Windows Xp. However, the code is not portable, as it fails to compile on Linux Red Hat. This is the command and the errors: # gcc -c time_loop.c time_loop.c: In function 'main':
6
2431
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 to some date), covering a large period from the past to the future. What would be nice would be a library which can take floating point seconds from an epoch. Does anyone know of a library which can convert from human style dates and times to a...
9
8301
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 following to try to determine which. import time # Determine if time.time is better than time.clock # The one with better resolution should be lower.
15
6442
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 but that only gave me difference in hours and only if the times were on the same day (after wrapping with date() function). TIA
0
9679
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10223
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10003
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9050
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6785
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5441
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4115
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3730
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2924
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.