Solved

Convert Date to interger in yyyymmdd format in Microsoft Expression Builder

Posted on 2014-11-05
10
864 Views
Last Modified: 2014-11-06
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
Comment
  • 5
  • 3
  • 2
10 Comments
 
LVL 24

Expert Comment

by:Phillip Burton
ID: 40424886
Your question does not make sense. The format command converts to a string, not a integer.
0
 

Author Comment

by:dcu_daily_processing_acl
ID: 40424903
I was trying a few different things. I am open to any suggestions.
0
 
LVL 26

Assisted Solution

by:Shaun Kline
Shaun Kline earned 250 total points
ID: 40424935
Have you tried something like this:
YEAR(Date) * 10000 + Month(DATE)  * 100 + Day(Date)
0
 

Author Comment

by:dcu_daily_processing_acl
ID: 40424940
Thanks Shaun, but could you be more specific? Would I just use a calculated function?
0
 
LVL 26

Expert Comment

by:Shaun Kline
ID: 40424987
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
Complete Microsoft Windows PC® & Mac Backup

Backup and recovery solutions to protect all your PCs & Mac– on-premises or in remote locations. Acronis backs up entire PC or Mac with patented reliable disk imaging technology and you will be able to restore workstations to a new, dissimilar hardware in minutes.

 

Author Comment

by:dcu_daily_processing_acl
ID: 40425025
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
 
LVL 24

Accepted Solution

by:
Phillip Burton earned 250 total points
ID: 40425128
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
 

Author Comment

by:dcu_daily_processing_acl
ID: 40425156
Well that worked perfectly. Thank you.
0
 
LVL 24

Expert Comment

by:Phillip Burton
ID: 40425731
You're welcome. Please award the points accordingly.
0
 

Author Closing Comment

by:dcu_daily_processing_acl
ID: 40426182
Thanks.
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Suggested Solutions

Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Via a live example, show how to setup several different housekeeping processes for a SQL Server.

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now