Solved

DateTime Comparison

Posted on 2006-11-11
6
353 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

 
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

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
Come and listen to Percona CEO Peter Zaitsev discuss what’s new in Percona open source software, including Percona Server for MySQL (https://www.percona.com/software/mysql-database/percona-server) and MongoDB (https://www.percona.com/software/mongo-…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

734 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