Comparing Military time and day of week

  • Thread starter Thread starter richardkreidl
  • Start date Start date
R

richardkreidl

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
 
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

--------------------
 
"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
 
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.
 
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/d.../vblr7/html/vaorivbruntimelibrarykeywords.asp

I hope this helps?

Cor
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Countif Function?? 3
Countif w/semicolon separated values 4
Shift Schedule Formula 1
Average of Day and Time 3
Min Value 5
If Command 1
Week and days query 8
Finding the right function & formula 4

Back
Top