Link to home
Start Free TrialLog in
Avatar of ross13
ross13Flag for United Kingdom of Great Britain and Northern Ireland

asked on

Week number in Crystal reports

I need to calculate the week number that we are currently in for a crystal report from a given date.
ASKER CERTIFIED SOLUTION
Avatar of reb73
reb73
Flag of Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
According to According to ISO 8601 the week starts on Monday, so the formula should be:

DatePart("ww",{Table.DateField},crMonday,crFirstFourDays)

In CR 11.0.0.1994 (and maybe later versions too) I discoverd a bug in this function for the dates 1-1-2010 until 3-1-2010. The function returns 9652 or 9653 instead of 53 !!

To workaround this bug use the formula:

IIF( DatePart("ww",{Table.DateField},crMonday,crFirstFourDays) > 53, 53,   DatePart("ww",{Table.DateField},crMonday,crFirstFourDays))