Tuesday, October 21, 2008

Reporting Services - Display Hour in 24 Hour Format with AM/PM

Recently I had a Requirement in SSRS 2005 to display a Report for Hourly Aggregation. The Report should look something like this:

Hour | Total
1 AM | 120
2 AM | 200
.
.
.
12 AM | 644
1 PM | 730
2 PM | 880
.
.
12 AM | 1458

---------------

In the Report Dataset using my SQL Query I got the Results like this

Hour | Total
1 | 120
2 | 200
3 | 328

So I had to display the Hour in 24 Hour format with AM/PM. I tried with various combinations of FormatDateTime() and Format(). Finally I found the format string - = Format(Today().AddHours(Fields!Hour.Value), "hh tt")

No comments:

Post a Comment