Connecting Tech Pros Worldwide Forums | Help | Site Map

Comparing Military time and day of week

richardkreidl@northwesternmutual.com
Guest
 
Posts: n/a
#1: Nov 21 '05
How would I check to see if the current time(military format) is
greater then 07:30AM and the day of the week is Monday-Friday.

Pseudo code:

If Current_Time > 07:30AM and Current_Day = Monday or Current_Day =
Tuesday _
or Current_Day = Wednesday or Current_Day = Thursday or Current_Day =
Friday
then
Do this
else
Do something else
end if


Alexandre Moura
Guest
 
Posts: n/a
#2: Nov 21 '05

re: Comparing Military time and day of week


Not sure if I understand what you mean by military time, but if it's just the hour attached to the minutes, then I might have a solution - cast the time to an
integer, and build a similarly formated date with:
if cint("730") > d.hour *100 + d.minute...

as for the rest, the date object has a dayofweek property you can use
if Now.DayOfWeek >= DayOfWeek.Monday And Now.DayOfWeek <= DayOfWeek.Friday then...

Mind you, this enum is sequential, but Sunday is the starting day (so it's value is 0)

Alex

--------------------[color=blue]
>From: "richardkreidl@northwesternmutual.com" <richardkreidl@northwesternmutual.com>
>Newsgroups: microsoft.public.dotnet.languages.vb
>Subject: Comparing Military time and day of week
>Date: 4 Mar 2005 12:42:50 -0800
>Organization: http://groups.google.com
>Lines: 15
>Message-ID: <1109968970.669832.176050@g14g2000cwa.googlegroups .com>
>NNTP-Posting-Host: 67.53.9.180
>Mime-Version: 1.0
>Content-Type: text/plain; charset="iso-8859-1"
>X-Trace: posting.google.com 1109968976 24783 127.0.0.1 (4 Mar 2005 20:42:56 GMT)
>X-Complaints-To: groups-abuse@google.com
>NNTP-Posting-Date: Fri, 4 Mar 2005 20:42:56 +0000 (UTC)
>User-Agent: G2/0.2
>Complaints-To: groups-abuse@google.com
>Injection-Info: g14g2000cwa.googlegroups.com; posting-host=67.53.9.180;
> posting-account=Ma6C7AwAAABwf3jndM8pyK2kS3uYbxvD
>Path: TK2MSFTNGXA02.phx.gbl!cpmsftngxa10.phx.gbl!TK2MSFT FEED02.phx.gbl!tornado.fastwebnet.it!tiscali!newsf eed1.ip.tiscali.net!news.glorb.com![/color]
postnews.google.com!g14g2000cwa.googlegroups.com!n ot-for-mail[color=blue]
>Xref: TK2MSFTNGXA02.phx.gbl microsoft.public.dotnet.languages.vb:263343
>X-Tomcat-NG: microsoft.public.dotnet.languages.vb
>
>How would I check to see if the current time(military format) is
>greater then 07:30AM and the day of the week is Monday-Friday.
>
>Pseudo code:
>
>If Current_Time > 07:30AM and Current_Day = Monday or Current_Day =
>Tuesday _
>or Current_Day = Wednesday or Current_Day = Thursday or Current_Day =
>Friday
>then
> Do this
>else
> Do something else
>end if
>
>[/color]


Michael C#
Guest
 
Posts: n/a
#3: Nov 21 '05

re: Comparing Military time and day of week


"Military Time" = 2400 hour clock. 00:01 = 12:01 AM (1 past midnight),
08:00 = 8:00 AM, 16:00 = 4 PM, 2359 = 11:59 PM. Can't test it myself right
now, but the DateTime object conversion might automatically account for
military time. Have you tried a DateTime conversion yet on your Military
Time string? If you can Convert to a DateTime, you should have access to
all DateTime functionality.

Thanks


"Alexandre Moura" <amoura@online.microsoft.com> wrote in message
news:tt2yuKQIFHA.1136@TK2MSFTNGXA02.phx.gbl...[color=blue]
> Not sure if I understand what you mean by military time, but if it's just
> the hour attached to the minutes, then I might have a solution - cast the
> time to an
> integer, and build a similarly formated date with:
> if cint("730") > d.hour *100 + d.minute...
>
> as for the rest, the date object has a dayofweek property you can use
> if Now.DayOfWeek >= DayOfWeek.Monday And Now.DayOfWeek <= DayOfWeek.Friday
> then...
>
> Mind you, this enum is sequential, but Sunday is the starting day (so it's
> value is 0)
>
> Alex
>
> --------------------[color=green]
>>From: "richardkreidl@northwesternmutual.com"
>><richardkreidl@northwesternmutual.com>
>>Newsgroups: microsoft.public.dotnet.languages.vb
>>Subject: Comparing Military time and day of week
>>Date: 4 Mar 2005 12:42:50 -0800
>>Organization: http://groups.google.com
>>Lines: 15
>>Message-ID: <1109968970.669832.176050@g14g2000cwa.googlegroups .com>
>>NNTP-Posting-Host: 67.53.9.180
>>Mime-Version: 1.0
>>Content-Type: text/plain; charset="iso-8859-1"
>>X-Trace: posting.google.com 1109968976 24783 127.0.0.1 (4 Mar 2005
>>20:42:56 GMT)
>>X-Complaints-To: groups-abuse@google.com
>>NNTP-Posting-Date: Fri, 4 Mar 2005 20:42:56 +0000 (UTC)
>>User-Agent: G2/0.2
>>Complaints-To: groups-abuse@google.com
>>Injection-Info: g14g2000cwa.googlegroups.com; posting-host=67.53.9.180;
>> posting-account=Ma6C7AwAAABwf3jndM8pyK2kS3uYbxvD
>>Path:
>>TK2MSFTNGXA02.phx.gbl!cpmsftngxa10.phx.gbl!TK2MS FTFEED02.phx.gbl!tornado.fastwebnet.it!tiscali!new sfeed1.ip.tiscali.net!news.glorb.com![/color]
> postnews.google.com!g14g2000cwa.googlegroups.com!n ot-for-mail[color=green]
>>Xref: TK2MSFTNGXA02.phx.gbl microsoft.public.dotnet.languages.vb:263343
>>X-Tomcat-NG: microsoft.public.dotnet.languages.vb
>>
>>How would I check to see if the current time(military format) is
>>greater then 07:30AM and the day of the week is Monday-Friday.
>>
>>Pseudo code:
>>
>>If Current_Time > 07:30AM and Current_Day = Monday or Current_Day =
>>Tuesday _
>>or Current_Day = Wednesday or Current_Day = Thursday or Current_Day =
>>Friday
>>then
>> Do this
>>else
>> Do something else
>>end if
>>
>>[/color]
>
>[/color]


Michael C#
Guest
 
Posts: n/a
#4: Nov 21 '05

re: Comparing Military time and day of week


Dim d As DateTime
d = Convert.ToDateTime("1/14/2005 13:00")
Console.WriteLine(d.ToString())

You can use the DateTime's .TimeOfDay property to get just the time, and you
can use the .DayOfWeek property to determine which Day of the Week your date
falls on.

Thanks,

Mike C.

<richardkreidl@northwesternmutual.com> wrote in message
news:1109968970.669832.176050@g14g2000cwa.googlegr oups.com...[color=blue]
> How would I check to see if the current time(military format) is
> greater then 07:30AM and the day of the week is Monday-Friday.
>
> Pseudo code:
>
> If Current_Time > 07:30AM and Current_Day = Monday or Current_Day =
> Tuesday _
> or Current_Day = Wednesday or Current_Day = Thursday or Current_Day =
> Friday
> then
> Do this
> else
> Do something else
> end if
>[/color]


Cor Ligthert
Guest
 
Posts: n/a
#5: Nov 21 '05

re: Comparing Military time and day of week


Richard,

Militairy time is used for the notation of the time in the US for the way it
is most standard done in the world. (Rarely is in the US and English Canada
(And non original Latin character writing "CocaCola" cultures) "am" and
"pm" used)

The time in datetime is in 100th nanoseconds ticks after 1/1/1, where the
starting time is in fact not that important.

When you want to do evaluating datetime you can always use the datetime
itself, however don't work with strings.

Beside the datetime methods and properties there are a lot of interesting
datetime methods in the VisualBasic namespace, by instance to get days of
the week.

http://msdn.microsoft.com/library/de...rykeywords.asp

I hope this helps?

Cor


Closed Thread


Similar Visual Basic .NET bytes