Solved

Problem comparing dates at midnight

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

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

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

This is pretty cool.  The purpose of this VB Script is to help you document where JAR (Java ARchive) files and specifically java class files are located so that you can address issues seen with a client or that you can speak intelligently with a dev…
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…
This video shows how to use Hyena, from SystemTools Software, to update 100 user accounts from an external text file. View in 1080p for best video quality.

738 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