![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | Using time conditions in vbs? Hello, Vista doesn't handle durations properly in the task scheduler, so I'm interested in building a time condition right into my vbscript file. Basically, here's what I need: If time of day is between 8:00AM and 5:00PM Then continue processing script Else end script End If Does anyone know how to write this in vbs? Thanks! |
My System Specs![]() |
| | #2 (permalink) |
| | Re: Using time conditions in vbs? "D.P. Roberts" <dproberts@xxxxxx> wrote in message news:OgyxQIxXJHA.2444@xxxxxx Quote: > Hello, > Vista doesn't handle durations properly in the task scheduler, so I'm > interested in building a time condition right into my vbscript file. > Basically, here's what I need: > > If time of day is between 8:00AM and 5:00PM Then > continue processing script > Else > end script > End If > > Does anyone know how to write this in vbs? > > Thanks! If Hour(Now()) >= 8 And Hour(Now()) < 17 |
My System Specs![]() |
| | #3 (permalink) |
| | Re: Using time conditions in vbs? That is exactly what I needed - thank you! "Pegasus (MVP)" <I.can@xxxxxx> wrote in message news:urLSZ$0XJHA.5312@xxxxxx Quote: > > "D.P. Roberts" <dproberts@xxxxxx> wrote in message > news:OgyxQIxXJHA.2444@xxxxxx Quote: >> Hello, >> Vista doesn't handle durations properly in the task scheduler, so I'm >> interested in building a time condition right into my vbscript file. >> Basically, here's what I need: >> >> If time of day is between 8:00AM and 5:00PM Then >> continue processing script >> Else >> end script >> End If >> >> Does anyone know how to write this in vbs? >> >> Thanks! > This should get you started: > If Hour(Now()) >= 8 And Hour(Now()) < 17 > > |
My System Specs![]() |
| | #4 (permalink) |
| | Re: Using time conditions in vbs? "Pegasus (MVP)" <I.can@xxxxxx> wrote in message news:urLSZ$0XJHA.5312@xxxxxx Quote: > > "D.P. Roberts" <dproberts@xxxxxx> wrote in message > news:OgyxQIxXJHA.2444@xxxxxx Quote: >> Hello, >> Vista doesn't handle durations properly in the task scheduler, so I'm >> interested in building a time condition right into my vbscript file. >> Basically, here's what I need: >> >> If time of day is between 8:00AM and 5:00PM Then >> continue processing script >> Else >> end script >> End If >> >> Does anyone know how to write this in vbs? >> >> Thanks! > This should get you started: > If Hour(Now()) >= 8 And Hour(Now()) < 17 > > possible to do date/time arithmetic in VBScript? I need to take the difference between 2 times and come up with the number of seconds that have passed, is this possible? thanks. Chip |
My System Specs![]() |
| | #5 (permalink) |
| | Re: Using time conditions in vbs? Chip Orange wrote on 18 dec 2008 in microsoft.public.scripting.vbscript: Quote: > I too need to understand time and it's possibilities in VBScript. Is > it possible to do date/time arithmetic in VBScript? I need to take > the difference between 2 times and come up with the number of seconds > that have passed, is this possible? Arguments interval Required. String expression that is the interval you want to use to calculate the differences between date1 and date2. See Settings section for values. date1, date2 Required. Date expressions. Two dates you want to use in the calculation. firstdayofweek Optional. Constant that specifies the day of the week. If not specified, Sunday is assumed. See Settings section for values. firstweekofyear Optional. Constant that specifies the first week of the year. If not specified, the first week is assumed to be the week in which January 1 occurs. See Settings section for values. Settings The interval argument can have the following values: Setting Description yyyy Year q Quarter m Month y Day of year d Day w Weekday ww Week of year h Hour n Minute s Second -- Evertjan. The Netherlands. (Please change the x'es to dots in my emailaddress) |
My System Specs![]() |
| | #6 (permalink) |
| | Re: Using time conditions in vbs? "Chip Orange" <Chip.Orange@xxxxxx> wrote in message news:O1dl6sJYJHA.2620@xxxxxx Quote: > > "Pegasus (MVP)" <I.can@xxxxxx> wrote in message > news:urLSZ$0XJHA.5312@xxxxxx Quote: >> >> "D.P. Roberts" <dproberts@xxxxxx> wrote in message >> news:OgyxQIxXJHA.2444@xxxxxx Quote: >>> Hello, >>> Vista doesn't handle durations properly in the task scheduler, so I'm >>> interested in building a time condition right into my vbscript file. >>> Basically, here's what I need: >>> >>> If time of day is between 8:00AM and 5:00PM Then >>> continue processing script >>> Else >>> end script >>> End If >>> >>> Does anyone know how to write this in vbs? >>> >>> Thanks! >> This should get you started: >> If Hour(Now()) >= 8 And Hour(Now()) < 17 >> >> > I too need to understand time and it's possibilities in VBScript. Is it > possible to do date/time arithmetic in VBScript? I need to take the > difference between 2 times and come up with the number of seconds that > have passed, is this possible? > > thanks. > > Chip It explains all of these basic VB Script functions. |
My System Specs![]() |
| | #7 (permalink) |
| | Re: Using time conditions in vbs? There is also a similar DateAdd function. Check the VBScript help files. To assign a date literal, enclose in "#" characters. For example: dtmStart = #Dec 18, 2008 10:00 AM# dtmEnd = DateAdd("d", dtmStart, 20) Wscript.Echo dtmStart Wscript.Echo dtmEnd lngSeconds = DateDiff("s", dtmStart, dtmEnd) Wscript.Echo CStr(lngSeconds) dtmStart = #Dec 18, 2008 10:00 AM# dtmEnd = #Jan 3, 2009 02:00 PM# lngSeconds = DateDiff("s", dtmStart, dtmEnd) Wscript.Echo CStr(lngSeconds) -- Richard Mueller MVP Directory Services Hilltop Lab - http://www.rlmueller.net -- "Evertjan." <exjxw.hannivoort@xxxxxx> wrote in message news:Xns9B7816EA3009eejj99@xxxxxx Quote: > Chip Orange wrote on 18 dec 2008 in microsoft.public.scripting.vbscript: > Quote: >> I too need to understand time and it's possibilities in VBScript. Is >> it possible to do date/time arithmetic in VBScript? I need to take >> the difference between 2 times and come up with the number of seconds >> that have passed, is this possible? > DateDiff(interval, date1, date2 [,firstdayofweek[, firstweekofyear]]) > > > Arguments > interval > Required. String expression that is the interval you want to use to > calculate the differences between date1 and date2. See Settings section > for values. > > date1, date2 > Required. Date expressions. Two dates you want to use in the calculation. > > firstdayofweek > Optional. Constant that specifies the day of the week. If not specified, > Sunday is assumed. See Settings section for values. > > firstweekofyear > Optional. Constant that specifies the first week of the year. If not > specified, the first week is assumed to be the week in which January 1 > occurs. See Settings section for values. > > Settings > The interval argument can have the following values: > > Setting Description > yyyy > Year > > q > Quarter > > m > Month > > y > Day of year > > d > Day > > w > Weekday > > ww > Week of year > > h > Hour > > n > Minute > > s > Second > > > > -- > Evertjan. > The Netherlands. > (Please change the x'es to dots in my emailaddress) |
My System Specs![]() |
| | #8 (permalink) |
| | Re: Using time conditions in vbs? "Pegasus (MVP)" <I.can@xxxxxx> wrote in message news:%23AcD11JYJHA.4772@xxxxxx Quote: > > "Chip Orange" <Chip.Orange@xxxxxx> wrote in message > news:O1dl6sJYJHA.2620@xxxxxx Quote: >> >> "Pegasus (MVP)" <I.can@xxxxxx> wrote in message >> news:urLSZ$0XJHA.5312@xxxxxx Quote: >>> >>> "D.P. Roberts" <dproberts@xxxxxx> wrote in message >>> news:OgyxQIxXJHA.2444@xxxxxx >>>> Hello, >>>> Vista doesn't handle durations properly in the task scheduler, so I'm >>>> interested in building a time condition right into my vbscript file. >>>> Basically, here's what I need: >>>> >>>> If time of day is between 8:00AM and 5:00PM Then >>>> continue processing script >>>> Else >>>> end script >>>> End If >>>> >>>> Does anyone know how to write this in vbs? >>>> >>>> Thanks! >>> >>> This should get you started: >>> If Hour(Now()) >= 8 And Hour(Now()) < 17 >>> >>> >> I too need to understand time and it's possibilities in VBScript. Is it >> possible to do date/time arithmetic in VBScript? I need to take the >> difference between 2 times and come up with the number of seconds that >> have passed, is this possible? >> >> thanks. >> >> Chip > I recommend that you download the file script56.chm from the Microsoft > site. It explains all of these basic VB Script functions. > I do have script56, but it wasn't clear to me (I don't remember where I was reading), if DateDiff would return only days or would do time arithmetic and return seconds. I'm coming from visual foxpro, which has a date and a date/time variable type, and can do arithmetic in either set of units returning the result based on the types used in the expression. thanks again, Chip Thanks again, Chip |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Multiple IF Conditions | VB Script | |||
| Changing the time zone changes the appointment time in calendar | .NET General | |||
| Internet Time Synchronization Incorrect - Showing Standard Time | PowerShell | |||
| Accept terms & conditions message for Excel worksheets | Vista General | |||