Solved

DateTime Comparison

Posted on 2006-11-11
6
343 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
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 
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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

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…
Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

747 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

11 Experts available now in Live!

Get 1:1 Help Now