Solved

DateTime Comparison

Posted on 2006-11-11
6
351 Views
Last Modified: 2010-04-23
I am trying to compare a date with another date.  Unfortunately, I am not being able to get a match even though they should.  The date is created with the Now() function placed in a database in a datetime field.  Then I get it from the database with myStructure.DateTime = CDate(record("ReminderDateTime")).  Below is output from the immediate window.  Any Ideas?

?st.DateTime.CompareTo(st2.DateTime)
-1

?st.DateTime
#11/11/2006 3:35:28 PM#

?st2.DateTime
#11/11/2006 3:35:28 PM#

?st.DateTime = st2.DateTime
False
0
Comment
Question by:kmcbrearty
  • 4
  • 2
6 Comments
 
LVL 29

Accepted Solution

by:
Nightman earned 500 total points
ID: 17922625
The values differ - probably only by a millisecond, but they differ. What do you get if you look at the millisecond value of these two? st1.Millisecond and st2.Millisecond?
0
 
LVL 29

Expert Comment

by:Nightman
ID: 17922632
Or even more granluar, st1.Ticks and st2.Ticks
0
 
LVL 3

Author Comment

by:kmcbrearty
ID: 17922804
I wasn't thinking about that.  I decided to use Now.ToString to assign the date.  I am not concerned with that much precision so it will work fine.
0
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 
LVL 29

Expert Comment

by:Nightman
ID: 17924562
OK, I have to ask. Why the B Grade?
0
 
LVL 3

Author Comment

by:kmcbrearty
ID: 17925455
While you pointed me in the right direction you didn't actually solve the issue.
0
 
LVL 29

Expert Comment

by:Nightman
ID: 17925506
Strictly speaking, your question was why they differed, not how to force them to be equal, but don't worry about it - I can live with a B.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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

Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

821 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