Link to home
Start Free TrialLog in
Avatar of dcu_daily_processing_acl
dcu_daily_processing_acl

asked on

Convert Date to interger in yyyymmdd format in Microsoft Expression Builder

I am writing a report in Microsoft Reporting Services and want to convert the date to an integer value in the format of yyyymmdd. However the obvious doesn't seem to be working:

=Format(Parameters!FirstPostDate.Value,"yyyymmdd")

Any help is appreciated.

Kris
Avatar of Phillip Burton
Phillip Burton

Your question does not make sense. The format command converts to a string, not a integer.
Avatar of dcu_daily_processing_acl

ASKER

I was trying a few different things. I am open to any suggestions.
SOLUTION
Avatar of Shaun Kline
Shaun Kline
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks Shaun, but could you be more specific? Would I just use a calculated function?
What is provided is just a formula to calculate an integer in the format you specified. You could use it as the value in a text box control, or in your query. However, what is the purpose of formatting a date in that format as an integer? If your desire is to display the date in that format in your report, there are other means to do this. For example, you could use the CONVERT function in your query. Or you could use that same function, but instead of the plus signs you could use ampersands to concatenate the values:
YEAR(Date) & RIGHT("0" & Month(DATE), 2)  & RIGHT("0" & Day(Date), 2)

BTW, if you are using SQL Reporting 2012 or higher, your original formula should work.
Shaun:

Thanks for the information. This is a rather large report and has four parameters. Two are in date format and two are in the integer format. I was setting the defaults to the parameters to be the first and last days of the previous month. I had no problem setting these for the date formatted parameters, but I have had no success doing this for the integer formatted parameters. So I was trying to convert the date formatted parameter values to create the default values for the integer formatted parameters in Microsoft Expression builder within the Parameter properties within SSRS. I apologize for not providing more information at the beginning of this question.
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Well that worked perfectly. Thank you.
You're welcome. Please award the points accordingly.