[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

check date time

Posted on 2013-11-13
1
Medium Priority
?
295 Views
Last Modified: 2013-11-14
How can I check time, if it is pass 12:17 PM and less than 13 pm?

if date.now.hour > 12 then
   'my code
end
0
Comment
Question by:VBdotnet2005
1 Comment
 
LVL 1

Accepted Solution

by:
_ChrisB earned 2000 total points
ID: 39646651
I saw a solution for this and thought I would share it with you.  Should do what you are looking for.

// convert everything to TimeSpan
TimeSpan start = new TimeSpan(12, 0, 0);
TimeSpan end = new TimeSpan(13, 0, 0);
TimeSpan now = DateTime.Now.TimeOfDay;
// see if start comes before end
if (start < end)
    return start <= now && now <= end;
// start is after end, so do the inverse comparison
return !(end < now && now < start);


stackoverflow.com/a/12998855
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
Integration Management Part 2
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
Suggested Courses
Course of the Month18 days, 14 hours left to enroll

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question