473,396 Members | 1,599 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,396 software developers and data experts.

Compare datetime in milliseconds

I'd like to compare two datetime values in milliseconds. The
datetime.compare method appears to show only seconds. Milliseconds of a
datetime are available as a property of each datetime, but I am assuming
there is an easier way than comparing the milliseconds, seconds, minutes,
hours, days, etc, individually to generate the difference.

Thanks in advance.

Mark
Aug 26 '06 #1
3 28423
Mark wrote:
I'd like to compare two datetime values in milliseconds. The
datetime.compare method appears to show only seconds. Milliseconds of a
datetime are available as a property of each datetime, but I am assuming
there is an easier way than comparing the milliseconds, seconds, minutes,
hours, days, etc, individually to generate the difference.
DateTime Compare returns negative, zero, positive.

If you simply subtract the two DateTime then you get a
TimeSpan where you can use the TotalMilliSeconds property.

Arne
Aug 26 '06 #2
Mark wrote:
I'd like to compare two datetime values in milliseconds. The
datetime.compare method appears to show only seconds. Milliseconds
of a datetime are available as a property of each datetime, but I am
assuming there is an easier way than comparing the milliseconds,
seconds, minutes, hours, days, etc, individually to generate the
difference.
Someone (possibly yourself) has led you astray about DateTime.Compare.

The DateTime struct is nothing but a fancy wrapper around the DateTime.Ticks
property - all other units are synthesized via simple algebraic
relationships (60 seconds in a minute, and so on).

DateTime.Compare compares the Ticks value, so there is no higher precision
comparison possible between DateTime objects than that provided by
DateTime.Compare.

-cd
Aug 26 '06 #3
Hi Mark,

Just in case you wonder what is Tick: a tick is the smallest unit of time
that can be specified. One millisecond = 10000 ticks. You can use the
TimeSpan.TotalMilliseconds to get the difference between two DateTime just
as Arne described.
Regards,
Walter Wang (wa****@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

Aug 28 '06 #4

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

Similar topics

2
by: prashanth | last post by:
Hi all, I am unable to write a javascript which will allow me to compare datetime entered by the user with the current datetime.( i.e the usertime should be less than or greater than currenttime)...
4
by: Viktor Jevdokimov | last post by:
Hello, I've got an XML file saved from DataSet. One table has datetime column (datatype - xs:dateTime). XML file fragment for example: <Root>...
0
by: Sunit Joshi | last post by:
Hello All I'm trying to figure out how to do this the best way. Basically, I need to compare DateTime of files across TimeZones. The situation is like this: 1. I have a database say in Korea...
12
by: conckrish | last post by:
Hi all.. Can anyone tell me how to compare datetime objects?I ve three objects namely Current date,start date and end date.. I need to check the current date with Start date and end date....Plz...
5
by: Mike | last post by:
Hi, I use MS SQL Express and VS 2005 c#, win application. I would like to select value rom DateTimePicker and list all values for selected date within GridView. I have method as follows: ...
3
by: =?Utf-8?B?U2FuZHBvaW50R3V5?= | last post by:
string dateTime = "5/28/2008"; DateTime.Compare(DateTime.Now,DateTime.Now) // returns 0 DateTime.Compare(DateTime.Now,DateTime.Parse(dateTime)) // returns 1 I need to compare 2 dates, using...
3
by: buntyindia | last post by:
Hi, I have a time related issue. Our application servers are hosted in US Central. So when cookie created by the application it contains US Central Time with DST. When we use it in India time...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.