Search code examples
reporting-servicesssrs-2012ssrs-2008-r2ssrs-tablix

SSRS 2012 date formatting


In SSRS 2012, I would like date to change a date to be in a specific format without changing the stored procedure that obtains the SQL Server date. This is due to the fact the stored procedure is extremely complex and I do not want to change it unless I absolutely have to.

Basically I would like the following:

  1. if the the date is in a basic datetime format, I would like a date like 06/03/2019 to look like Monday, June 3, 2019 for the English formatting.

  2. For a Spanish version of the date is 6/3/2019, I would like the Spanish version of the date to be in the same format.

Thus would you show me the SQL on how to accomplish this goal?


Solution

  • This TSQL will work with SQL 2012, the language for SQL server is Español in this example.

    SET DATEFORMAT yyyymmdd
    DECLARE @date as DATE
    SET @date = '20190603'
    SELECT @@LANGUAGE AS SQL_Language, FORMAT ( @date, 'D') AS 'Date'
    

    The results set returned is this

    enter image description here

    The FORMAT() function can output datetime in a variety of formats for more details see this web page.

    SSRS reports can also support datetime formatting if required. See this answer for more details.