In this article, we will show you how to Format Date and Time in SSRS Report. It is one of the Frequently asked questions by users. So, here we will show you the step by step approach to format Date and Time in SSRS Report using the text box properties and the Expression with an example.
To explain the available SSRS Date format and Time Format options, We are going to use the below-shown DataSet. Please refer to Embedded Data Source and Dataset articles to understand the steps involved in creating Embedded Data Source and Dataset that we used for this SSRS report.
And the Custom SQL query that we used in the above Dataset is:
-- Formatting Date and Time on SSRS Report SELECT [FirstName] + ' ' + [LastName] AS FullName ,[Education] ,[Occupation] ,[YearlyIncome] ,[Sales] ,[HireDate] FROM [Employee]
Data written by the above query is:
Format Date and Time in SSRS Report
To explain the list of Data format and Time format options, we are going to use the below-shown report.
Please refer to the Table Report article to understand the steps involved in creating the Table Report, and refer to the Format Table article to understand the formatting. Next, see Add headers and Footer for adding Page headers and footers.
Let me show you the Report Preview. Here, our task is to format the Hire Date column in this Report
We had two approaches to format Date and Time in SSRS: one is using the Text Box Properties, and the other is using an expression. Let me explain the First option here, and later we will show the second option.
The first approach to Format Data and Time in SSRS Report
To format the date, please select the TextBox containing Date values. In this example, Select the Hire Date Text box of the report, and Right-click on it will open the context menu. Please select the Text Box Properties.. option from it
Once we click on the Text Box Properties.. option, a new Text Box Properties window will be opened. Please select the Number tab and then the date category.
To format date in SSRS, please change the default date time format to Monday, January 31, 2000 1:30 PM
As you can see from the below screenshot that our report is displaying the Formatted Date and Time in the Hire Date column
Again, Let me change the date time format to Monday, January 31, 2000 1:30:00 PM
As you can see from the below screenshot that our report displays the Date and Time with AM and PM in the Hire Date column. I hope you understand the format date.
This time, we will try the shortest date format 31 Jan 2000
Our report preview displays the Hire date in the same format.
If you observe the Number tab in TextBox properties, we have another category called Time. This category is useful to format time (exclusively). Let me select the format as 31-Jan-00 1:30 PM
Our report preview is displaying the Hire date in the same format.
Format Date and Time in SSRS Report using Expression
It’s a second approach and the most advanced approach to format data and time in SSRS Report.
The reporting service supports Expressions, and it is one of the dominant concepts available for developers. If your desired format is not in the list of categories, then you can use Expression to write a custom date and time.
Please select Hire Date TextBox of the report, and Right-click on it will open the context menu. Please select the Expression.. option from it
Once you choose the Expression.. option, a new window called an Expression opens. Under the category section -> Common Functions -> Date and Time, we have many dates and time functions. We can use any of the functions or combinations of functions to achieve the desired result.
For this example, we are formatting the Hire date to a short date
As you can see, the Hire date column is saying that it holds an Expression, rather than the Column name Hire date.
See, our report preview is displaying the same in the Hire date column data.