Convert a date to an integer in YYYYMMDD format in SSRS

久未见 提交于 2020-01-23 02:56:05

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!