Convert a date to an integer in YYYYMMDD format in SSRS
13,973
Assuming you have a date parameter called YourDate
.
You could use the following expression:
=Cint(Format(Parameters!YourDate.Value, "yyyyMMdd"))
Explanation:
Step 1: Format the date to the yyyyMMdd
format:
Format(Parameters!YourDate.Value, "yyyyMMdd")
Step 2: Cast the result as an int:
Cint(<FormattedDate>)
Comments
-
Jim W. almost 2 years
What is the equivalent expression in SSRS of the following conversion of a date (@Date) in T-SQL?
CONVERT(INT,CONVERT(CHAR,@Date,112))
I need the date parameter value to be converted to an integer in YYYYMMDD format.
-
Jim W. almost 9 yearsThanks, JC. I started down a similar path: =YEAR(Parameters!MyDate.Value)*10000 + MONTH(Parameters!MyDate.Value)*100 + DAY(Parameters!MyDate.Value) But, the alternate method suggested by Sébastien Sevrin works well too and is a little shorter: =Cint(Format(Parameters!MyDate.Value, "yyyyMMdd"))