Solved

Set Default Parameters for Previous Month

Posted on 2010-08-13
6
572 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
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Written by Valentino Vranken. Introduction: The first step of creating a SQL Server Reporting Services (SSRS) report involves setting up a connection to the data source and programming a dataset to retrieve data from that data source.  The data…
Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
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…
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.

706 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now