Solved

Problem comparing dates at midnight

Posted on 2014-12-29
2
96 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 500 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

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

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

Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

724 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