Solved

500pts: Is Time > 08:15 in the morning?

Posted on 2006-11-01
3
196 Views
Last Modified: 2010-04-16
Hi there,

Can anybody tell me how to find out if the current time using NOW is greater than a certain time

if ( DateTime.Now.AddMinutes(-5).ToShortTimeString() >= thisMarket.OpenTime.ToShortTimeString()  )

 thisMarket.OpenTime is DateTime and contains 08:15

I need for it to return true if it is anywhere from 08:10 (notice the -5) to 00:00

I hope someone can help

Thanks in advance

ian

0
Comment
Question by:ianinspain
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 13

Accepted Solution

by:
joechina earned 250 total points
ID: 17852790
double diff = thisMarket.OpenTime.TimeOfDay.TotalSeconds - DateTime.Now.TimeOfDay.TotalSeconds;

(diff > 0 and diff <= 60*5)   returns true if the time is between 8:10 to 8:15

(diff > 0 and diff > 60*5) returns true if the time is between 0:00 to 8:10
0
 
LVL 20

Assisted Solution

by:TheAvenger
TheAvenger earned 250 total points
ID: 17852948
Don't compare strings - this is a source of errors. You can just compare the times. Also you need to add 5, not subtract them, if you are searching for times between 8:10 and 00:00

if (DateTime.Now.AddMinutes(5).TimeOfDay >= thisMarket.OpenTime.TimeOfDay)
  // Do whatever you want
0
 

Author Comment

by:ianinspain
ID: 17853188
thanks both!

Much appreciated

Ian
0

Featured Post

[Live Webinar] The Cloud Skills Gap

As Cloud technologies come of age, business leaders grapple with the impact it has on their team's skills and the gap associated with the use of a cloud platform.

Join experts from 451 Research and Concerto Cloud Services on July 27th where we will examine fact and fiction.

Question has a verified solution.

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

This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

628 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