473,385 Members | 1,474 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Time Comparison

mc
How to do a time comparison?

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.782 / Virus Database: 528 - Release Date: 22/10/2004
Nov 16 '05 #1
4 13871
Hi,
How to do a time comparison?


You should look for:
DateTime.Compare(...)
DateTime.CompareTo(...)

eventually:
DateTime.Subtract(...)

HTH
Marcin
Nov 16 '05 #2
mc
Hi,

Suppose I want my program to do something at 1pm everyday, how do I do the
comparison?

Thanks.

"Marcin Grzębski" <mg*******@taxussi.no.com.spam.pl> wrote in message
news:cm**********@atlantis.news.tpi.pl...
Hi,
How to do a time comparison?


You should look for:
DateTime.Compare(...)
DateTime.CompareTo(...)

eventually:
DateTime.Subtract(...)

HTH
Marcin

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.782 / Virus Database: 528 - Release Date: 22/10/2004
Nov 16 '05 #3
mc,

You don't use a DateTime to do it. This is a task for Scheduled Tasks.
You would write your program so that it performs the action once, and then
set up the Scheduled Tasks to run your program at 1 PM every day.

There is no need to run a program or a service which does nothing except
at a certain time to perform tasks.

--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"mc" <mi*******@accuplace.com> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl...
Hi,

Suppose I want my program to do something at 1pm everyday, how do I do the
comparison?

Thanks.

"Marcin Grzębski" <mg*******@taxussi.no.com.spam.pl> wrote in message
news:cm**********@atlantis.news.tpi.pl...
Hi,
How to do a time comparison?


You should look for:
DateTime.Compare(...)
DateTime.CompareTo(...)

eventually:
DateTime.Subtract(...)

HTH
Marcin

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.782 / Virus Database: 528 - Release Date: 22/10/2004

Nov 16 '05 #4
mc,
As Nicholas suggests, this sounds like a scheduled task.

When I want to compare "times" without the date part I normally use
TimeSpan.Compare:

Something like:

TimeSpan now = DateTime.Now.TimeOfDay;

TimeSpan onePM = TimeSpan.FromHours(13);

if (TimeSpan.Compare(now, onePM) < 0)
DoSomething();

I created a TimeRange object (in VB.NET) that is a little more flexibly then
the above sample. For details see:

http://groups.google.com/groups?q=ti...phx.gbl&rnum=2

Hope this helps
Jay

"mc" <mi*******@accuplace.com> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl...
Hi,

Suppose I want my program to do something at 1pm everyday, how do I do the
comparison?

Thanks.

"Marcin Grzębski" <mg*******@taxussi.no.com.spam.pl> wrote in message
news:cm**********@atlantis.news.tpi.pl...
Hi,
How to do a time comparison?


You should look for:
DateTime.Compare(...)
DateTime.CompareTo(...)

eventually:
DateTime.Subtract(...)

HTH
Marcin

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.782 / Virus Database: 528 - Release Date: 22/10/2004

Nov 16 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

21
by: Javier | last post by:
Hi I´ve a routine that will read date and times in a vector of strings ie: 30/02/2005 19:20 In some moment I´ll need to check if there are in vector a date like current date with a time...
6
by: teddysnips | last post by:
I have a table called WorkItem. It models a chunk of work done during a working day. It has two columns that I'm interested in: Start (smalldatetime) - the TIME the work block is begun...
68
by: Roman Ziak | last post by:
Hello, I just downloaded MS Visual Studio 2005 Express Beta. When I tried to compile existing valid project, I get a lot of warnings like 'sprintf' has been deprecated, 'strcpy' has been...
21
by: SSG | last post by:
Hi All! I want to know how to display the system time without using--system("date"). can anyone give me the idea to handle this operation. By S.S.G
3
by: Chandu | last post by:
Hi, I am working on awk programming which is similar to C programming and have got a doubt about time function returning a float value. Ex: 01:01:30 should return 61.5 when i have tried my way i...
6
by: Jim C. Nasby | last post by:
Is there any reason why there isn't a predefined cast to go from a timestamp to a varchar? Is there a reason not to add one? -- Jim C. Nasby, Database Consultant jim@nasby.net...
37
by: spam.noam | last post by:
Hello, Guido has decided, in python-dev, that in Py3K the id-based order comparisons will be dropped. This means that, for example, "{} < " will raise a TypeError instead of the current...
3
by: Joey Martin | last post by:
Please look at code below. I am trying to compare the NOW time with a "deadline" time. Please help. Just not sure why this is not working. I need to be able to say IF IT'S BEFORE 9:30 TODAY, IT'S...
1
by: Lars B | last post by:
Hey guys, I have written a C++ program that passes data from a file to an FPGA board and back again using software and DMA buffers. In my program I need to compare the size of a given file against...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.