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
dcu_daily_processing_aclAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
Phillip BurtonConnect With a Mentor Director, Practice Manager and Computing ConsultantCommented:
If you are trying to convert a date to integer, try this:

=year(Parameters!FirstPostDate.Value)*10000+month(Parameters!FirstPostDate.Value)*100+day(Parameters!FirstPostDate.Value)
0
 
Phillip BurtonDirector, Practice Manager and Computing ConsultantCommented:
Your question does not make sense. The format command converts to a string, not a integer.
0
 
dcu_daily_processing_aclAuthor Commented:
I was trying a few different things. I am open to any suggestions.
0
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
Shaun KlineConnect With a Mentor Lead Software EngineerCommented:
Have you tried something like this:
YEAR(Date) * 10000 + Month(DATE)  * 100 + Day(Date)
0
 
dcu_daily_processing_aclAuthor Commented:
Thanks Shaun, but could you be more specific? Would I just use a calculated function?
0
 
Shaun KlineLead Software EngineerCommented:
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.
0
 
dcu_daily_processing_aclAuthor Commented:
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.
0
 
dcu_daily_processing_aclAuthor Commented:
Well that worked perfectly. Thank you.
0
 
Phillip BurtonDirector, Practice Manager and Computing ConsultantCommented:
You're welcome. Please award the points accordingly.
0
 
dcu_daily_processing_aclAuthor Commented:
Thanks.
0
All Courses

From novice to tech pro — start learning today.