Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Problem comparing dates at midnight

Posted on 2014-12-29
2
Medium Priority
?
98 Views
Last Modified: 2014-12-29
I have two dates, both at midnight
e.g. 06/06/2014 and 12/29/2014
Both dates are exactly midnight (at least they should be), they are in datetime format and show no time section
I am using adddays to add 1 day each time in a loop until the
1st date = 2nd date
Problem is that even though on debug the dates eventually look equal, they are never equal and the loop continues.
I have also compared them in an if statement and they are not equal but they look the same.
Any help most welcome.
0
Comment
Question by:SweetingA
[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
2 Comments
 
LVL 40

Accepted Solution

by:
Jacques Bourgeois (James Burger) earned 2000 total points
ID: 40522356
How do you display the dates?

The "look" is dependent on the format used for the diplay. If the time is not specifically requested, then it might not display.

Try the following in your loop and then look at result in the Output window. You can activate it from the Debug menu if it is not visible:

Debug.WriteLine(String.Format("{0:MM/dd/yyyy hh:mm:ss}", FirstDate) & " --- " & String.Format("{0:MM/dd/yyyy hh:mm:ss}", SecondDate) & " --- " & FirstDate.Millisecond & " --- " & SecondDate.Millisecond)

Open in new window


The first 2 values will show you if there is a time recorded, and the last 2 if there are milliseconds recorded in the date. These never display by default, but they can make the difference.
0
 

Author Comment

by:SweetingA
ID: 40522377
Acrually the output did not display (unsure why) but the answer was clear - some millseconds in the 2nd date

Thanks a lot
0

Featured Post

Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

Question has a verified solution.

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

A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …

610 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