vincent strobbe
vincent strobbe

Reputation: 23

SSRS calculate timedifference between two times HH:MM:SS

I want to know the time difference between two times.

i have 2 string in format HH:MM:SS that i want to compare and know the timedifference

(string) starttime = 12:13:14 AND (string) endtime = 12:13:18 >> the difference should be 4 seconds

I tried something and normally i think that the datediff should do the magic.

DateDiff("s",CDate(Fields!starttime.Value) , CDate(Fields!endtime.Value))

After that i would convert the seconds to a timestamp HH:MM:SS

But the reponse is always 0 (seconds)

Can anyone help me out with this ?

Thanks in advance

Upvotes: 0

Views: 567

Answers (1)

Alan Schofield
Alan Schofield

Reputation: 21683

This is untested but...

If you are only checking times that occur on the same day then you could add an arbitrary date before the time.

Something like

=DateDiff("s",
          CDate("2020-01-01 " & Fields!starttime.Value) , 
          CDate("2020-01-01 " & Fields!endtime.Value)
         )

Upvotes: 1

Related Questions