'Comparing dates works on one machine but not on another

I have an issue where on one machine comparing dates fails and on another it passes. I'm using Assert.AreEqual:

Assert.AreEqual(Convert.ToDateTime(tableValue).Date, 
Convert.ToDateTime(detailsValue).Date);

and the dates I'm comparing are "10/07/2018 04:17:02" and "10/07/2018". It's the same project cloned from the same repo. I thought it has something to do with culture settings but I couldn't get to a solution. Does anyone have any idea what could be the reason?



Solution 1:[1]

Thanks for your replays. This is what I concluded:

Assert.AreEqual(Convert.ToDateTime(tableValue).**Date**, 
Convert.ToDateTime(detailsValue).**Date**);

on one machine Date was taking into calculation only date part (that's why it passed) and on another it took date and time (that's why it failed). Don't know why. But when I changed it to:

Assert.AreEqual(Convert.ToDateTime(tableValue).**Seconds**, 
Convert.ToDateTime(detailsValue).**Seconds**);

it calculates in seconds so it fails every time and everywhere as it should so that kind of resolved my problem.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 beginner501