Solved

Set Default Parameters for Previous Month

Posted on 2010-08-13
6
584 Views
Last Modified: 2012-08-14
On the beginning of every month,  I intend to run a report for the previous month.   I want to keep the default format YYYYMMDD. So for example, if I ran the report on August I would lke SSRS to default my @startDate and @EndDate as the previous month, but don 't know the syntax to find last day of month for @EndDate

@StartDate = Format(dateadd("M", -1, today()), "yyyyMM")+"01"
@EndDate =  20100731

0
Comment
Question by:epicazo
6 Comments
 
LVL 5

Expert Comment

by:KiasChaos83
ID: 33434498
0
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 33434644
I cannot speak for SSRS, however in T-SQL you would use something like this:
SELECT DATEADD(DAY, -DAY(GETDATE()), DATEDIFF(DAY, 0, GETDATE()))
0
 
LVL 10

Expert Comment

by:itcouple
ID: 33436412
Hi

Try this
=format(dateadd("d",-day(today())-1,today()), "yyyyMMdd")

Regards
Emil
0
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.

 
LVL 10

Accepted Solution

by:
itcouple earned 250 total points
ID: 33436420
sorry

Try this
=format(dateadd("d",-day(today()),today()), "yyyyMMdd")
0
 
LVL 5

Expert Comment

by:robertg34
ID: 33438232

select 
dateadd(mm,datediff(mm,0,getdate())-1,0) [FirstDate], 
dateadd(dd,-1,dateadd(mm,datediff(mm,0,getdate()),0)) [LastDate]

Open in new window

0
 

Author Closing Comment

by:epicazo
ID: 33439286
thank you all !
0

Featured Post

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

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

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.
The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
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 combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.

839 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