Solved

Set Default Parameters for Previous Month

Posted on 2010-08-13
6
590 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
[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
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
Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

 
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

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

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

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.
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

636 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