Forum Discussion
Comparing Date portion of datetime fields
- 5 years ago
INT(FirstDate)<=INT(SecondDate)Date Time values are decimal numbers where the integer portion is the number of days since 12/30/1899 and the time portion is the decimal portion and is in fractions of a day hours/24 + minutes/60 + seconds/3600. So, if you use INT to just return the integer portions to do the comparison, you are good to go.
AllisonKennedy Well, it used to handle them really poorly where it would add 1900 to the value or something bizarre like that. However now it appears that dates prior to 12/30/1899 just go negative so 12/29/1899 is -1, etc. I believe it has the same leap year built in like Excel but would need to confirm. Also, Excel starts at 1/1/1900 as 1, so not exactly the same.
Have confirmed the leap year - Power BI will not allow the 29 Feb, 1900 as a valid date, but Excel does. So starting from March 1, 1900 both Power BI and Excel use the same INT value for dates.
Whereas Excel does not view anything before Jan 1, 1900 as a valid date.
This is the kind of nerdy stuff I love learning!