SSRS Expressions: Format Dates & Numbers

Aim: To format dates & numbers embedded in text strings in SQL Server Reporting Services.

To embed formatted dates in text strings, set the expression for the text string to:

="From " + Format(Parameters!StartDate.Value, "yyyy-MM-dd") + " to " + Format(Parameters!EndDate.Value, "yyyy-MM-dd")

E.g. for @StartDate = 01/02/2017 & @EndDate = 31/03/2017, the string will appear in the report as:
From 2017-02-01 to 2017-03-31

Changing the date format, e.g. from “yyyy-MM-dd” to “dd/MM/yyyy”, will change how the text string appears in the report.


To embed formatted numbers in text strings, set the expression for the text string to:

="Value: " + CStr(Round(Parameters!TotalValue.Value, 2))

E.g. for @Number = 5.1234, the string will appear in the report as:
Value: 5.12

Changing the numeric rounding value, e.g. from 2 to any other number, will change how the text string appears in the report.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Kevin Kline

Career and Technical Advice for the IT Professional

TroubleshootingSQL

Explaining the bits and bytes of SQL Server and Azure

SQL Authority with Pinal Dave

SQL Server Performance Tuning Expert

Powershellshocked

A blog about PowerShell and general Windows sysadmin stuff

Simon Learning SQL Server

I'm trying to become "better" at SQL Server and data - here's how I'm doing it!

%d bloggers like this: