问题
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.
回答1:
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>)
回答2:
Dry coding here, but try...
=Fields!MyDateColumn.Value.Year * 10000 + Fields!MyDateColumn.Value.Month * 100 + Fields!MyDateColumn.Value.Date
回答3:
Try the following expression :-
=format(cdate(Parameters!Date.Value),"yyyyMMdd")
来源:https://stackoverflow.com/questions/31253180/convert-a-date-to-an-integer-in-yyyymmdd-format-in-ssrs