Solved

check date time

Posted on 2013-11-13
1
287 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 500 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
insert value of checklistbox checked 4 32
Need help with a Crystal Report in my C#.Net application 2 27
tableview is not updating 1 20
linq, c# 8 23
Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

838 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