Reputation: 2784
I want to print start, end and elapsed time on the report but nothing seems to work.
="Elapsed: " + CStr(Now - CDate(Globals!ExecutionTime))
throws an error while
=Now - CDate(Globals!ExecutionTime)
prints elapsed time. I need to incorporate elasped time into a larger sentence. FormatDateTime throws an error re System.TimeSpan cannot be converted to Date.
What is the correct formula to print a string of how long the report took to generate?
I know that a workaround is to keep elapsed time in its own text box, but formatting requirements call for one concatenated string of all three times.
Upvotes: 0
Views: 1308
Reputation: 39566
This might give you some ideas:
="Start: " & Globals!ExecutionTime.ToString() & vbcrlf
& "End: " & Now().ToString() & vbcrlf
& "Elapsed: " & DateDiff(DateInterval.Minute
, Globals!ExecutionTime
, Now()) mod 60
& ":"
& Right("0" & DateDiff(DateInterval.Second
, Globals!ExecutionTime
, Now()) mod 60
, 2)
This gives a result of:
Which looks like what you might be after.
I'm just using vbcrlf
as a line break.
The most important part is the Elapsed
part, which uses DateDiff
to get the difference between the two datetimes to get minute and second portions and displays this as mm:ss
. You could adapt to your specific needs.
Upvotes: 3