?
Solved

Convert Date to interger in yyyymmdd format in Microsoft Expression Builder

Posted on 2014-11-05
10
Medium Priority
?
1,123 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 27

Assisted Solution

by:Shaun Kline
Shaun Kline earned 1000 total points
ID: 40424935
Have you tried something like this:
YEAR(Date) * 10000 + Month(DATE)  * 100 + Day(Date)
0
Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

 

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 27

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
 

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 1000 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

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed

719 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