on 12-19-2012 11:03 PM
In Crystal Reports 2011, I'm trying to return the first day of the week in the date format m/d/yyyy for a specific week of a prior year. For example, December 2, 2012 is the 49th week of 2012 and begins on a Sunday. However 365 days prior to December 2, 2012 is a Saturday and still in the 49th week of 2011. Is there a function in Crystal that will allow for this? I've been unsuccessful in finding one. In the end, what I'm trying to do is to determine the sales for the same week of the prior year. Any help is appreciated!
To get the Monday for any date, try this:
{date} - DayOfWeek({date}, crMonday) + 1
If I call that formula {@Monday} then the formula to get the week of the year is something like this:
DateDiff('ww', Date(Year({@Monday}), {@Monday}, crMonday)
-Dell
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Ron,
In order to calculate the week-over-week comparison between given years you would need to write a series of formulas. You can test the approach given in the following thread:
http://www.crystalkeen.com/articles/crystalreports/calculateweeknumber.htm
Note:- Scroll to the bottom of the page to go through the entire article.
Thanks,
Prathamesh
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Ron,
you can use following formula to return the date 365 prior to date stored in DB
datediff("d",-365,{<Database date field>};
however this will not consider if previous year was a leap year or not.
If you want we can modify the formula using if else constuucts to consider leap years also.
I hope this would help
Regards,
Shantanu
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
78 | |
10 | |
9 | |
7 | |
6 | |
6 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.