Solved

DateTime Comparison

Posted on 2006-11-11
6
349 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Form design in vb.net 7 35
code conversion from excel vba to visual basic for visual studio 5 41
Close word object 13 38
vb.net checkbox 7 41
This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

862 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now