Solved

Set Default Parameters for Previous Month

Posted on 2010-08-13
6
585 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
Edgartown IT Case Study

Learn about Edgartown's quest to ensure the safety and security of the entire town's employee and citizen data. Read the case study!

 
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

Edgartown IT Case Study

Learn about Edgartown's quest to ensure the safety and security of the entire town's employee and citizen data. Read the case study!

Question has a verified solution.

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

Occasionally there is a need to clean table columns, especially if you have inherited legacy data. There are obviously many ways to accomplish that, including elaborate UPDATE queries with anywhere from one to numerous REPLACE functions (even within…
This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties

685 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