Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Set Default Parameters for Previous Month

Posted on 2010-08-13
6
Medium Priority
?
591 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
The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

 
LVL 10

Accepted Solution

by:
itcouple earned 1000 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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

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
When trying to connect from SSMS v17.x to a SQL Server Integration Services 2016 instance or previous version, you get the error “Connecting to the Integration Services service on the computer failed with the following error: 'The specified service …
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.
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.

722 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