Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1158
  • Last Modified:

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
0
dcu_daily_processing_acl
Asked:
dcu_daily_processing_acl
  • 5
  • 3
  • 2
2 Solutions
 
Phillip BurtonCommented:
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
 
Shaun KlineLead Software EngineerCommented:
Have you tried something like this:
YEAR(Date) * 10000 + Month(DATE)  * 100 + Day(Date)
0
Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

 
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
 
Phillip BurtonCommented:
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
 
dcu_daily_processing_aclAuthor Commented:
Well that worked perfectly. Thank you.
0
 
Phillip BurtonCommented:
You're welcome. Please award the points accordingly.
0
 
dcu_daily_processing_aclAuthor Commented:
Thanks.
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

  • 5
  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now