Hi I have two date times that I belive to be equal. However, when I do a
comparison I find that date1 is less than date2...
Console.WriteLine(date1.ToString("dd/MM/yyyy HH:mm:fffffff") + " - " +
date2.ToString("dd/MM/yyyy HH:mm:fffffff"))
.... which ouputs: 12/11/2003 14:23:4370000 - 12/11/2003 14:23:4370000 in the
console window.... this is as much info as DateTime can handle right? So we
know that they are equal?? Then I try the actual comparison...
Console.WriteLine(DateTime.Compare(date1, date2))
....which ouputs -1. Although it should output 0. Whats going on here?
--
Cheers,
elziko 4 4542
dates can sometimes do strange things :/
1 way around this is to convert them to strings and compare them ( i dont
know if you are lookiung for something like this but just in case ;))
'dont use the :fffffff if you dont really need them
if date1.ToString("dd/MM/yyyy HH:mm:fffffff") = date2.ToString("dd/MM/yyyy
HH:mm:fffffff") then
Console.WriteLine("0")
else
Console.WriteLine("-1")
end if
hope it helps
eric
"elziko" <el****@NOTSPAMMINGyahoo.co.uk> wrote in message
news:3f***********************@news.easynet.co.uk. .. Hi I have two date times that I belive to be equal. However, when I do a comparison I find that date1 is less than date2...
Console.WriteLine(date1.ToString("dd/MM/yyyy HH:mm:fffffff") + " - " + date2.ToString("dd/MM/yyyy HH:mm:fffffff"))
... which ouputs: 12/11/2003 14:23:4370000 - 12/11/2003 14:23:4370000 in
the console window.... this is as much info as DateTime can handle right? So
we know that they are equal?? Then I try the actual comparison...
Console.WriteLine(DateTime.Compare(date1, date2))
...which ouputs -1. Although it should output 0. Whats going on here?
--
Cheers,
elziko
> 1 way around this is to convert them to strings and compare them
I will eventually need to know that if the dates are not equal then which
one precedes the other? There must be a way of doing this without resorting
to creating strings and writing my own comparison code... thats pretty
inefficient especially when you need to do a lot of them I'd imagine.
I may look into converting them to ticks and comparing them... maybe this
would be more efficient that strings.
Thanks anyway though!
--
Cheers,
elziko
"elziko" <el****@NOTSPAMMINGyahoo.co.uk> schrieb Hi I have two date times that I belive to be equal. However, when I do a comparison I find that date1 is less than date2...
Console.WriteLine(date1.ToString("dd/MM/yyyy HH:mm:fffffff") + " - " + date2.ToString("dd/MM/yyyy HH:mm:fffffff"))
... which ouputs: 12/11/2003 14:23:4370000 - 12/11/2003 14:23:4370000 in the console window.... this is as much info as DateTime can handle right? So we know that they are equal?? Then I try the actual comparison...
Console.WriteLine(DateTime.Compare(date1, date2))
...which ouputs -1. Although it should output 0. Whats going on here?
Why not output the seconds?
date1.ToString("dd/MM/yyyy HH:mm:ss.fffffff")
--
Armin http://www.plig.net/nnq/nquote.html http://www.netmeister.org/news/learn2quote.html
Well Iwent the ticks route and found the source of my problems... the way in
which I was storing and retrieving my data meant that the two dates were
always a few ticks different for some reason.... not sure why so now I'm
subtracting one from the other and ignoring differences of less than a
second.
--
Cheers,
elziko
"Armin Zingler" <az*******@freenet.de> wrote in message
news:O0**************@TK2MSFTNGP11.phx.gbl... "elziko" <el****@NOTSPAMMINGyahoo.co.uk> schrieb Hi I have two date times that I belive to be equal. However, when I do a comparison I find that date1 is less than date2...
Console.WriteLine(date1.ToString("dd/MM/yyyy HH:mm:fffffff") + " - " + date2.ToString("dd/MM/yyyy HH:mm:fffffff"))
... which ouputs: 12/11/2003 14:23:4370000 - 12/11/2003 14:23:4370000 in the console window.... this is as much info as DateTime can handle right? So we know that they are equal?? Then I try the actual comparison...
Console.WriteLine(DateTime.Compare(date1, date2))
...which ouputs -1. Although it should output 0. Whats going on here?
Why not output the seconds?
date1.ToString("dd/MM/yyyy HH:mm:ss.fffffff") -- Armin
http://www.plig.net/nnq/nquote.html http://www.netmeister.org/news/learn2quote.html This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Donnal Walter |
last post by:
I was very surprised to discover that
>>> import datetime
>>> x = datetime.date(2004, 9, 14)
>>> y = datetime.datetime(2004, 9, 14, 6, 43, 15)
>>> print x == y
True
How can these two...
|
by: colinhumber |
last post by:
I have a datetime variable coming from my ASP.NET application that has
a time portion. I give my users the option to perform an equals,
greater than, less than, or between comparison. The trouble...
|
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>...
|
by: mayamorning123 |
last post by:
A comparison among six VSS remote tools including SourceOffSite ,
SourceAnyWhere, VSS Connect, SourceXT, VSS Remoting, VSS.NET
To view the full article, please visit...
|
by: Joe Van Meer |
last post by:
Hi all,
Do dates & time values always get inserted according to the user's main
language setting in their browser? Like, if I had an application that
somehow relied on comparing dates and...
|
by: rhaazy |
last post by:
I need to know how I can format a string in C# to get the current date/
time, so that I can do a comparison against a date time column in MS
SQL Server 2005.
The date/time column in the database...
|
by: Anil Gupte |
last post by:
I am using the followig code:
SqlConnection con = new SqlConnection(strcon);
con.Open();
string strSelect = "Select PaidUntil from Users where username='" + un +
"'";
SqlCommand cmd = new...
|
by: Sreenivas |
last post by:
Hi every one,
I need to compare to datetime values , done in
stored procedure.The input datetime parameter is in
dd/mm/yyyy hh:mm:ss AM/PM format ,the datetime values to be compared
are also...
|
by: indika |
last post by:
Hi,
I'm a newbie to python but have some experience in programming.
I came across this requirement of using datetime.date objects
associated with some another object.
eg. a dictionary containing...
|
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
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
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...
|
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...
|
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: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...
| |