Forum Discussion
Need help calculating the difference between two dates and times
- Dec 01, 2022
HassaanAhmed Calculating with dates and times like this is tricky. you need to introduce the MOD function to take only the decimal part of the date.time value.
By the way, I prefer to calculate with the TIME function when adding hours. See attached.
Note also that the 00:00 hour should always be the last hour for the day. On row 14 you had this hour on September 1.
Riny_van_EekelenThanks. I tried doing that already, but the result flips after 12 pm.
As you can see below, the time difference between the two times should still be -12 even after 12 pm, but it doesn't pick it up that way.
HassaanAhmed Please include a screenshot that shows the formula you entered and the column and row headers.
- HassaanAhmedDec 01, 2022Copper Contributor
- Riny_van_EekelenDec 01, 2022Platinum Contributor
HassaanAhmed Thanks,
Can't reproduce that outcome for the rows where the time difference goes positiv in your screenshot.
See attached file as well.
- HassaanAhmedDec 01, 2022Copper Contributor
Riny_van_Eekelen Thanks for the prompt responses!
Attaching the file here for your reference.
Could the reason be that I'm creating the time series by adding the excel decimal value for an hour to the cell above (row 2 and below in columns B and D)? If that's the problem, then can you guide me to a better way of generating a list of dates and times for each hour of every day in a month?