Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Change only the YYYY part of a date param

Status
Not open for further replies.

cisscott

IS-IT--Management
Apr 21, 2003
115
US
CR 9.1
MS SQL Server 2K

I am designing a report that I would like to have ask for 3 parameters: Begin Date, End Date, and Year of Comparison. The report will summarize the deposits received in the current year (using Begin Date-End Date). I would also like it to pull the exact same period in the Year given by the Year parameter, group that data, and summarize it so that it the two can be compared. However, I'm having trouble figuring out how to set up the selection formula. Here is an examle of what Im having trouble with:

Begin date Parameter chosen = 04/01/2005
End date Parameter chosen = 04/30/2005
Comparison Year chosen = 2003

Now i want the report to pull data for the given date range, and also for the exact same date range in the year 2003. How do I take the Begin date and end date parameters and modify them to contain the value "2003" in the year portion? I know it would be easier for me to just have 2 more date range params, but I want to get better at manipulating date data, and I think the report would be a little more polished with this method. Thanks in advance for any advice offered.
 
Ahh, nevermind, figured it out, using a combination of Cdate and Datepart... However, Im still all ears if someone knows a slicker way. Thanks !
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top