SSRS Report Expression for Hour basis

Hi All,

time was like 10:40:45 → 10:00 AM

18:23:47 → 06:00 PM

09:01:40 → 09:00 AM

13:59:49 → 01:00 PM

need time in hours only in ssrs report expression.


I don’t know if it can be done in an expression, therefore I wouldn’t do it. I would round values in AX before sending them to the report.

By the way, I see you haven’t attached any version tag. Which version of AX are you talking about?

Thanks Martin,

can you please suggest some round for time? version D365 F&O.

Round functions for time field?

There are multiple ways how to do. Here is one of them:

TimeOfDay time = timeNow();

int hours = real2int(time / #SecondsPerHour);
TimeOfDay roundedTime = hours *  #SecondsPerHour;

yes but here i want only hours sir. like if suppose 06:44:55 it is has to show 06:00 AM. i dont want minutes and seconds.

Sorry, I thought your examples above showed what you wanted, e.g. 18:23:47 → 06:00 PM. Are you saying you actually want 18:23:47 → 18?

If so, you should be able to do it in expressions quite easily. Just use HOUR() function, e.g. =Hour(Fields!MyField.Value).

If you want to do it in X++, look at my code sample again - you’ll see that you already have the value there, in the variable called hours (assigned at line 5).