Solved

Convert Date to interger in yyyymmdd format in Microsoft Expression Builder

Posted on 2014-11-05
10
971 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
Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

 

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
 

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
LTrim & Double Space Correction 5 41
where to find DTS instalation package for sql 2014 64 bit 3 11
changing page verifacation 1 30
xml files 7 29
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…
Citrix XenApp, Internet Explorer 11 set to Enterprise Mode and using central hosted sites.xml file.
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.
With the advent of Windows 10, Microsoft is pushing a Get Windows 10 icon into the notification area (system tray) of qualifying computers. There are many reasons for wanting to remove this icon. This two-part Experts Exchange video Micro Tutorial s…

831 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