time compare

i need an example of how to code a time comparison.
i need to check to see if a value in a date/time column is greater than 10 
minutes from the current time.
i appreciate your help.
thanks,
mcnewsxp 


0
Michael
10/8/2010 1:25:43 PM
scripting.vbscript 564 articles. 0 followers. Follow

12 Replies
3443 Views

Similar Articles

[PageSpeed] 37

On Fri, 8 Oct 2010 09:25:43 -0400, "Michael Courter"
<mcourter@mindspring.com> wrote:

>i need an example of how to code a time comparison.
>i need to check to see if a value in a date/time column is greater than 10 
>minutes from the current time.
>i appreciate your help.
>thanks,
>mcnewsxp 
>

Difftime()

-ralph
0
ralph
10/8/2010 2:07:35 PM
Michael Courter wrote:
> i need an example of how to code a time comparison.
> i need to check to see if a value in a date/time column is greater
> than 10 minutes from the current time.
> i appreciate your help.
> thanks,
> mcnewsxp

What database? Type and version please. "Date/time" sounds like Jet...
 Do you want to do this in a query? Or in your vbscript code?
-- 
HTH,
Bob Barrows


0
Bob
10/8/2010 2:12:26 PM
ralph wrote:
> On Fri, 8 Oct 2010 09:25:43 -0400, "Michael Courter"
> <mcourter@mindspring.com> wrote:
>
>> i need an example of how to code a time comparison.
>> i need to check to see if a value in a date/time column is greater
>> than 10 minutes from the current time.
>> i appreciate your help.
>> thanks,
>> mcnewsxp
>>
>
> Difftime()
>
What's that?

-- 
HTH,
Bob Barrows


0
Bob
10/8/2010 2:12:46 PM
On Fri, 8 Oct 2010 10:12:46 -0400, "Bob Barrows"
<reb01501@NOyahoo.SPAMcom> wrote:

>ralph wrote:
>> On Fri, 8 Oct 2010 09:25:43 -0400, "Michael Courter"
>> <mcourter@mindspring.com> wrote:
>>
>>> i need an example of how to code a time comparison.
>>> i need to check to see if a value in a date/time column is greater
>>> than 10 minutes from the current time.
>>> i appreciate your help.
>>> thanks,
>>> mcnewsxp
>>>
>>
>> Difftime()
>>
>What's that?

ha. Good question. 

Wrong newsgroup.

-ralph
0
ralph
10/8/2010 2:23:50 PM
ralph wrote:
> On Fri, 8 Oct 2010 10:12:46 -0400, "Bob Barrows"
> <reb01501@NOyahoo.SPAMcom> wrote:
> 
>> ralph wrote:
>>> On Fri, 8 Oct 2010 09:25:43 -0400, "Michael Courter"
>>> <mcourter@mindspring.com> wrote:
>>>
>>>> i need an example of how to code a time comparison.
>>>> i need to check to see if a value in a date/time column is greater
>>>> than 10 minutes from the current time.
>>>> i appreciate your help.
>>>> thanks,
>>>> mcnewsxp
>>>>
>>> Difftime()
>>>
>> What's that?
> 
> ha. Good question. 
> 
> Wrong newsgroup.

The VBS version is DateDiff()
-- 
Crash

"When you get to a fork in the road, take it."
~ Yogi Berra ~
0
Dave
10/8/2010 2:54:01 PM
"Bob Barrows" <reb01501@NOyahoo.SPAMcom> wrote in message 
news:i8n8sg$h6t$1@news.eternal-september.org...
> Michael Courter wrote:
>> i need an example of how to code a time comparison.
>> i need to check to see if a value in a date/time column is greater
>> than 10 minutes from the current time.
>> i appreciate your help.
>> thanks,
>> mcnewsxp
>
> What database? Type and version please. "Date/time" sounds like Jet...
> Do you want to do this in a query? Or in your vbscript code?
> -- 

thanks for the responses.  i worked it out with code.  was simpler than i 
thought. 


0
mcnewsxp
10/8/2010 4:38:13 PM
Michael Courter <mcourter@mindspring.com> typed:

>i need an example of how to code a time comparison.
> i need to check to see if a value in a date/time column is greater
> than 10 minutes from the current time.
> i appreciate your help.

If DateDiff("s", dtime, Now) > 10 * 60 Then

DateDiff(/interval/, date1, date2 [,firstdayofweek[, firstweekofyear]])

The interval argument must be one of the following values:

    Expression      Corresponds to
      yyyy          Years
      q             Quarters
      m             Months
      y             Days of year
      d             Days
      w             Weekdays
      ww            Weeks of year
      h             Hours
      n             Minutes
      s             Seconds

But watch out: If you want to calculate the lifetime of a man in years,
then you have to compare the days, not the years, this would become
wrong dependent from the given birthdate:

DateDiff("yyyy", dtmBirthdate, Now)

In my case it would become right, because I was born at the beginning of
the year.

-- 
ЯR

0
Ruediger
10/8/2010 7:25:37 PM
In microsoft.public.scripting.vbscript message <4caf703d$0$6771$9b4e6d93
@newsspool3.arcor-online.net>, Fri, 8 Oct 2010 21:25:37, Ruediger
Roesler <worm.composter@nospam.arcornews.de> posted:

>
>But watch out: If you want to calculate the lifetime of a man in years,
>then you have to compare the days, not the years,


No; you take the difference in years, and subtract one if the current
year's birthday has not been reached.  A further correction, depending
on applicable convention, may be needed if the person was born on
February 29th and it is now February 28th of a year which is not a Leap
year.  Germany probably has a Law about it.

-- 
 (c) John Stockton, nr London, UK.    ?@merlyn.demon.co.uk     Turnpike v6.05.
 Website  <http://www.merlyn.demon.co.uk/> - w. FAQish topics, links, acronyms
 PAS EXE etc. : <http://www.merlyn.demon.co.uk/programs/> - see in 00index.htm
 Dates - miscdate.htm estrdate.htm js-dates.htm pas-time.htm critdate.htm etc.
0
Dr
10/9/2010 5:42:35 PM
Dr J R Stockton wrote:
> In microsoft.public.scripting.vbscript message <4caf703d$0$6771$9b4e6d93
> @newsspool3.arcor-online.net>, Fri, 8 Oct 2010 21:25:37, Ruediger
> Roesler <worm.composter@nospam.arcornews.de> posted:
> 
>> But watch out: If you want to calculate the lifetime of a man in years,
>> then you have to compare the days, not the years,
> 
> No; you take the difference in years, and subtract one if the current
> year's birthday has not been reached.  A further correction, depending
> on applicable convention, may be needed if the person was born on
> February 29th and it is now February 28th of a year which is not a Leap
> year.  Germany probably has a Law about it.

Achtung! This should work:
'------------------------------------------
DOB=cDate("02/29/1960") 'Format to fit system date format

on error resume next
bday=cDate(month(DOB) & "/" & day(DOB) & "/" & year(Date))
if err.number then
	bday=cDate(month(DOB) & "/" & day(DOB)-1 & "/" & year(Date))
	err.clear
end if

age=year(Date)-year(DOB)
if DateDiff("d", bday,Date)<0 then age=age-1
'---------------------------------------------
-- 
Crash

"Never underestimate the power of the Dark Side."
~ Obi-Wan Kenobi ~
0
Dave
10/10/2010 12:20:15 PM
Dr J R Stockton <reply1040@merlyn.demon.co.uk> typed:

>>But watch out: If you want to calculate the lifetime of a man in
>>years, then you have to compare the days, not the years,
>
>
> No; you take the difference in years, and subtract one if the current
> year's birthday has not been reached.  A further correction, depending
> on applicable convention, may be needed if the person was born on
> February 29th and it is now February 28th of a year which is not a
> Leap year.  Germany probably has a Law about it.

Ok, you are right, my example was badly selected. My statement did not
refer to the leap years. DateDiff returns only the intervals between two
dates, it does not compute the absolute value which lies between two
given dates.

'########################### CalcDate.vbs #############################
' Execute this script only with CScript.exe as host!

dtmDate1 = CDate(DateSerial(2008, 2, 1) & " " & TimeSerial(0, 0, 0))
dtmDate2 = CDate(DateSerial(2009, 2, 1) & " " & TimeSerial(0, 0, 0))

WScript.Echo vbCRLF & "This are the number of intervals between " & _
             FormatDateTime(dtmDate1, vbLongDate) & " and " & _
             FormatDateTime(dtmDate2, vbLongDate) & ":"
arr = Array("yyyy", "Year", "q", "Quarters", "m", "Months", "y", _
            "Days of year", "d", "Days", "w", "Weekdays", "ww", _
            "Weeks of year", "h", "Hours", "n", "Minutes", "s", _
            "Seconds")
For i = 0 To UBound(arr) Step 2
    WScript.Echo vbTab & DateDiff(arr(i), dtmDate1, dtmDate2) & " " & _
                                                            arr(i + 1)
Next

str = "Please enter your birthdate: "
Do
    WScript.StdOut.Write vbCRLF & str
    str = WScript.StdIn.ReadLine
    If IsDate(str) Then dtmBirthdate = CDate(str)
    If dtmBirthdate > Now Then dtmBirthdate = Empty
    str = "Please enter your *correct* birthdate: "
Loop Until IsDate(dtmBirthdate)

WScript.Echo vbCRLF & "You were born on " & _
             FormatDateTime(dtmBirthdate, vbLongDate)
WScript.Echo "Today you are " & DateDiff(arr(0), dtmBirthdate, Now) & _
             " years old."
If DateDiff(arr(0), dtmBirthdate, Now) > 120 Then
    WScript.Echo "You are too old for living."
End If
'########################### CalcDate.vbs #############################

The result of this script is not correct in any case.

I have no notion about that, to what extent there are laws for leap
years in Germany. I believe, the priests decide on it, when the annual
length is customised to the actual conditions. Maybe I am wrong. ;-)

-- 

ЯR

0
Ruediger
10/10/2010 1:57:56 PM
this works for me:
<% if (minute(time) - minute(objRs("last_call")) > 10) or (minute(time) - 
minute(objRs("last_call")) < 0) then %> 


0
mcnewsxp
10/10/2010 6:36:53 PM
mcnewsxp wrote on 10 okt 2010 in microsoft.public.scripting.vbscript:

> this works for me:
> <% if (minute(time) - minute(objRs("last_call")) > 10) or
> (minute(time) - minute(objRs("last_call")) < 0) then %> 

Ofcourse this "works for you",
if you want the execution to succeed 50 minutes out of every hour of last 
call occurance from the beginning to the end of time. 

say time is 11:11:02 [24h mode]

then 1492-12-12 11:27:17 [Columbus in America?] would pass,
as would 2027-01-01 16:59:17 [Obama's 5th term in office?],
but 0070-08-14 13:15:19 [Titus in Jerusalem?] would not


-- 
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
0
Evertjan
10/10/2010 7:31:51 PM
Reply:

Similar Artilces:

Compare Sheets #2
I'm going insane I'm trying to compare two sheets using Walkenbach's approach but for some reason when I use it...certain values don't show differences. Example: Sheet 1 (Range Name is Grid) has 18000 on Cell A1 Sheet 2 (Range Name is OldGrid) has 18000 on Cell A2 So if I change Cell A1 on Sheet 1 to 1 it should show me change but no...it just does nothing. However if I type 133...it shows change. Selection.FormatConditions.Add Type:=xlExpression, Formula1:= _ "=COUNTIF(OldGrid,A1)=0" Selection.FormatConditions(1).Interior.ColorIndex = 40 Help really appreciate...

How can i use a command button to validate date and time
I have two command buttons, each on a different sheet. i need both of them to put the current date in one cell on its sheet and current time in another on its sheet. i also need these cells to be locked so the user can only edit these cells by clicking the command button. Any answers? ...

Importing Item List for the first time
We are currently change over from Quickbooks Accounting 2002 Pro to MS Retail Management System and need to know the easist way to import item list into MS POS. -- Dan Hausbeck Dan, Easiest is to upgrade to QB 2003 or higher. Then follow these instructions; https://mbs.microsoft.com/knowledgebase/KBDisplay.aspx?scid=kb;en-us;836444 Otherwise, does 2002 give you the ability to export a report to Excel? If so, create a report of your inventory items, export to an Excel file and then use the unsupported RMS Import Utility, again in CustomerSource. I think you are going to _have_ to upda...

Make outlook run as if its the first time
Hello How do I make outlook run as if it is the first time? I messed with the settings... pleaseeeeeeee help! Guy >How do I make outlook run as if it is the first time? >I messed with the settings... pleaseeeeeeee help! Uninstall it and reinstall it. What settings did you change that no longer meet your requirements? Why not simply change them back? -- Brian Tillman Smiths Aerospace 3290 Patterson Ave. SE, MS 1B3 Grand Rapids, MI 49512-1991 Brian.Tillman is the name, smiths-aerospace.com is the domain. I don't speak for Smiths, and Smiths doesn't speak for me. "Br...

Converting Numbers to Time (A second probelm)
Due to several peoples help in this group I learned some very helpful date/time functions but here is one that has since eluded me... What I am trying to do it convert... 1/6/1900 22:40:25 to the total number of hours and seconds. As if the start date was 1/1/1900 00:00:00. Or in other words I have a start date of 4/6/2005 11:54:53 End date of 4/7/2005 14:07:00 Total time of 1/1/1900 2:12:07 How do i convert the 1/1/1900 2:12:07 into 26:12:07 Thanks for all your help, Steve smonczka@hotmail.com Just format the answer cell as [hh]:mm:ss -- HTH Bob Phillips "Smonczka" <...

Pulling Kronos Activity Time Into Great Plains
Does anyone one know how to import labor hours into Great Plains 8.0? We use Kronos Workforce Activities to track our labor time. Use Integration Manager or eConnect. -- Charles Allen, MVP "Chad A" wrote: > Does anyone one know how to import labor hours into Great Plains 8.0? We use > Kronos Workforce Activities to track our labor time. ...

Help! Search & Replacing time formats
Hi I have a whole spreadsheet full of fields similiar to the following 10:00AM 12:15PM 2:25PM 4:40PM 7:00PM 9:20PM 10:00PM 12:20PM 2:25PM 4:30PM 7:15PM 10:00AM 12:30PM 2:45PM 9:15PM 10:40AM 1:10PM 5:00PM 7:20PM 9:35PM etc. I need to convert all times to 24 hour, and drop the AM & PM. The later is easy, but how do I do a quick Search & Replace without incorrectly converting 10:**AM to 22:** etc. Any tips would be appreciated. ------------------------------------------------ ~~ Message posted from http://www.ExcelTip.com/ ~~ View and post usenet messages directly fro...

Time Card setups
Hello, We are implementing HR for a client. What is the best practice in importing Time Code assignments to employees and establishing beginning leave balances? -- Greg. ...

Add time to a date time group
Hi, thanks for any help in advance I have my date and time displayed in this format dd hhmm "K" mmm yy which shows up as 03 1800 K Sep 08. I would like a formula that will add 30 min to this time group so it becomes 03 1830 K Sep 08 Assume your date/time is in A1, then you can do this in another cell: =3DA1+30/24/60 Format the cell in the same way as A1 (using the Format Painter icon). Times are stored in Excel as fractions of a 24-hour day, hence the divisions by 24 and 60. Hope this helps. Pete On Sep 4, 12:28=A0am, Patrick <Patr...@discussions.microsoft.com> wr...

Cube View required to count Milestones over time
I have a basic Data Analysis view which counts milestones over time..however I now what to count a breakdown of those milestones over time..I have Milestone types 1,2 and 3. I have created a Milestone Type custom field at task level to set a value against each milestone ie 1, 2 or 3. How do I then get this Milestone Type field into the Cubes in order to add it to the view? Which cube should I be using etc?? ...

Average interpurchase times
Table is organized like this: Date Purchase Quantity 01/02/2010 12 01/23/2010 45 05/04/2010 10 07/06/2010 5 .... How do I calculate the average time between purchase? Thank you for any help you can provide. Drew Yallop -- Drew Yallop SELECT Avg([Date]-DMin("[Date]","Yallop")) AS AvgDaysBetweenPurchases FROM Yallop; BTW: Date is a very bad name for a field or table. It's a reserved word and can cause problems if you forget to put the [ ] around it. Read more about reserved words at: http://supp...

Run Time Error 3711
I get this run error occsionally on a machine with Store Operations Manager running XP Pro. Run Time Error 3711 I would appreciate any help. Tony ...

use a time value in a bar graph
i have values in a series like c5 9:01 d5 21:01 e5 =(d5-c5) I would like to use e5 in a bar graph it gives values which would make sense only to excel If the axis is formatted as time, it shouldn't be a problem. If it doesn't choose the scales to give clean divisions, you can choose an appropriate unit on the axis, such as 03:00. -- David Biddulph "pdfrone" <pdfrone@discussions.microsoft.com> wrote in message news:A8C14E9F-104A-464A-81B6-39DA2C679E71@microsoft.com... >i have values in a series > > like > > c5 9:01 > d5 21:01 > e5 =(d5-c5...

Outlook Multiple Profiles at the Same Time
I have two separate icons set up on my desktop to call Outlook using /profiles switch for profiles A & B. I can double click one for A, and it opens my POP3 account for profile A. Then I close it and double click one for B, then it opens my Exchange Server account for profile B. The problem is if I don't close the one for profile A and try to open the one for B, then even if the switch is set to open profile B, it just opens profile A again. Can someone tell me how I can have two separate Outlook for two separate profiles open at the same time? Adding POP3 to my Exchange S...

Suming Up Time over the course of days
I have a sheet the contains event durations on specific days. Some days have more than one event. I would like to add up all the event times for each day on a second sheet and (line) chart the results there. The list get longer with each event. Tuesday Nov.2 2010 10:16 am 00:37:22 Tuesday Nov.2 2010 08:28 am 00:15:48 Monday Nov.1 2010 08:30 am 01:03:07 Sunday Oct.31 2010 06:36 pm 00:09:20 Sunday Oct.31 2010 06:17 pm 00:03:26 Sunday Oct.31 2010 05:27 pm 00:07:42 Sunday Oct.31 2010 11:15 am 00:27:19 Sunday Oct.31 2010 08:56 am 00:45:26 Saturday Oct.30 2010 12:44 pm ...

Solved! (This time for sure!
Wait... Bullwinkle? Boris? Hmmm.... Boris, I owe you. I never in a million years would have guessed it was the icon, but that's exactly what it was. I just got an e-mail from the client. The system now works 100%. If by chance you are on facebook, please add me as a friend, or just send me an e-mail sometime - discgolfdad@cox.net And say "Hi!" to Natasha for me! I don't know Bullwinkle, and Boris is not my real name, but I'm glad it works now! Cheers!! On Sat, 17 Apr 2010 14:06:40 +0200, Boris Pauljev <nordiccoder@hotmail.com> wrote...

One link breaks every time I open a workbook...
I have 3 workbooks tied together with links. One is a source only, the other two push and pull data. One of the sources, Payroll Master, on opening updates all links fine to the source only workbook but not to the third workbook (which is in the parent directory). Every time I open it it prompts me to show it where the Payroll Entry is. Doesn't matter if I hit cancel and do Edit Links, I can change it there, but will still lose it upon closing (the link appears in the box and looks ok, just won't update...) Try going Edit->Links. Break the link and re-establish it? That m...

Max. no. of characters in a message box line is less in Vista when compared with XP
Hi, I have noticed in Vista, the maximum no. of characters which could be displayed in a messagebox line is 85 characters where in XP it was 131 characters. Following is a summary when compared this with OSes, OS - Max. no. of characters per messagebox line. XP - 131 Vista, Windows 7 - 85 Windows2008 Server x32 and x64 - 81 Following is a code in VB to run in Vista simulate the problem which spans into 3 lines, where it was expected in 2 lines. MsgBox ("**Maximum number of characters per messagebox line in Windows Vista is 85 characters.**"+CHR(13)+CHR(10)+"...

limit time for outgoing emails
Hi all, I`m running exchange 5.5 sp4. I wanted to know if it possible to control the time that mail can stay in the outbound of the mail internet connection or the number of time that exchange retry to send them? If it possible, what is recomended? Thank for the help, Tom I cant remember the exact location, but you can adjust those values on the IMS. Poke around, you'll find it. On Thu, 3 Jun 2004 19:47:44 -0400, "Tom" <tom@israelemb.org> wrote: >Hi all, >I`m running exchange 5.5 sp4. >I wanted to know if it possible to control the time that mail can stay i...

VB "run time error"
Hello, I was just wondering if anyone knows of a fix for a VB "run time error". I try and access a table and it's givng me an error message saying run time error. Any help would be great. Thanks. "Busty" <mrmarbles316@hotmail.com> wrote: >I was just wondering if anyone knows of a fix for a VB "run time error". I >try and access a table and it's givng me an error message saying run time >error. What is the exact error message? Tony -- Tony Toews, Microsoft Access MVP Please respond only in the newsgroups so that others can ...

Tracking Time
Hi all, i want to build a time tracking function in order to track each occasion a record in Table A is being updated. Table B stores the Time, Now(), Name, fOSUserName() and a field related to the Key field of table A. When a record in the form related to table A is updated (on the Before update event) i want this to be recorded in Table B... Question: Do i need a separate form (not visible) to capture this data or can i code Form A, on the Before Update event or on the Close event, to update the related record in Table B? Thanks! Hi Peter What you are trying to do ...

How do I sample hourly data one time per day
I have hourly data from an instrument and would like to reduce the data set (see example below) to one point per day, either by selecting a specific time (e.g., 00:00) each day, or by averaging all of the values for one day. The data files may contain more than one month's worth of data per file (i.e., quite large files). 8/11/2006 00:00 17.06 8/11/2006 01:00 17.05 8/11/2006 02:00 17.05 8/11/2006 03:00 17.05 8/11/2006 04:00 17.05 8/11/2006 05:00 17.05 8/11/2006 06:00 17.06 8/11/2006 07:00 17.06 8/11/2006 08:00 17.05 8/11/2006 09:00 17.06 8/11/2006 10:00 17.06 8/11/2006 11:00 17.06 8...

Daylight saving time Strange behaviour
Hi, I have created an application where I am using CTime( int nYear,int nMonth,int nDay,int nHour,int nMin,int nSec,int nDST = -1); Constructor to change the dates to UTC before saving them to database. I have set my timezone to Easterntime(US&Canada) which is 5 hrs behind GMT. I entered the following date, 01\11\2006 12:00:00PM.When its converted to UTC,the date its showing is 01\11\2006 4:00:00PM. In 2006,DST ended on 29\10\2006,thus ideally it should show 01\11\2006 5:00:00PM. This behaviour is shown for dates ranging from 30\10\2006 to 4\11\2006. Analysing the issue,I checked my...

Subtracting military times (decimal format)
I apologize if this has been asked & answered many times before, bu after reading for days in this forum, I can not find a direct answer t my needs. I have timecards that are already displayed in military/decimal format I do not want to convert to hours/minutes and I'm not interested i displaying results in hh:mm format. I do not want the date displayed. simply want to calculate each employees total time worked for thei shift's "start" to "end" (keeping the decimal format). Results are no rounded...employees are paid for all fractional hours. There are no se...

Count the number of times a character appears in a field
This is a multi-part message in MIME format. ------=_NextPart_000_001B_01CAD018.FC830D40 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit How can I count the number of times the @ symbols appears in a text field. ------=_NextPart_000_001B_01CAD018.FC830D40 Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: quoted-printable <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML><HEAD> <META content=3D"text/html; charset=3Dus-ascii" = http-equiv=3DCon...