How do I use if statement to determine which method to use based on specified time?

momokesh

Member
Joined
Dec 13, 2016
Messages
12
Programming Experience
1-3
What I need help with is (if statements) how to determine which method to use (to run a process) based on specified weekday time. Dates are irrelevant.
How do I use specified time to decide the method to use?
I do not need help with the process or even the methods. All I need help with is if statements to determine which method to use.




Requirements
Method AllDocuments
If the time is 8 AM to 9 AM AllDocuments method is used
If the time is 11 AM - 11:05 AM AllDocuments method is used
If the time is 1 PM - 1:05 PM AllDocuments method is used
If the time is 3 PM - 3:05 PM AllDocuments method is used
If the time is 5 PM - 5:05 PM AllDocuments method is used




Method GetDocsInLast60Minutes
If the time is 9 AM to 5 PM GetDocsInLast60Minutes method is used
 
What I need help with is (if statements) how to determine which method to use (to run a process) based on specified weekday time. Dates are irrelevant.
How do I use specified time to decide the method to use?
I do not need help with the process or even the methods. All I need help with is if statements to determine which method to use.




Requirements
Method AllDocuments
If the time is 8 AM to 9 AM AllDocuments method is used
If the time is 11 AM - 11:05 AM AllDocuments method is used
If the time is 1 PM - 1:05 PM AllDocuments method is used
If the time is 3 PM - 3:05 PM AllDocuments method is used
If the time is 5 PM - 5:05 PM AllDocuments method is used




Method GetDocsInLast60Minutes
If the time is 9 AM to 5 PM GetDocsInLast60Minutes method is used
DateTime.Now has a few properties, like Hour (uses 24hour time) and Minute, so you just need a series of If statements checking if the Hour equals a value, like 8 or 9 then AllDocuments() gets called, otherwise there's if Hour equals 11 and (&&) Minute greater than equals 0 and (&&) minute less than equal 5 then AllDocuments() gets called.
 
I did follow what you said and it is now working. Thanks. Now I would like to know how to figure out if the day is Saturday or Sunday. How do I do that?
 
I did follow what you said and it is now working. Thanks. Now I would like to know how to figure out if the day is Saturday or Sunday. How do I do that?
Since you're now familiar with the DateTime.Now properties, care to take a guess as to which one will tell you the day of the week?
 

Latest posts

Back
Top Bottom