1282626 - How do display weeknumber in ISO format in Crystal Reports?

SAP Knowledge Base Article - Public

1282626 - How do display weeknumber in ISO format in Crystal Reports?

Symptom

Crystal Reports displays the week number 53 for the first week of January instead of week number 1.

Reproducing the Issue

  • Create a new report using Xtreme Sample Database
  • Use the Order table to get the Order Date
  • Create the following formula to add 5 years to Order Date:date(dateadd("yyyy",5,{Order.Order Date}))
  • Create a second formula to get the corresponding calendar week:datepart("ww",{Order.Order Date},crMonday,crFirstFourDays)
  • Run the report

Crystal Reports XI Release 2

Cause

This problems is by design. The function DatePart() is designed to work the same way as in Visual Basic and hence returns 53. More information can be found on the Microsoft website.

Resolution

Workaround:

Use the following formula in the report:

if tonumber(Cstr(datepart("WW",#30/12/2009#,crMonday,crFirstJan1),'##0')) > 52 then 1 else
tonumber(Cstr(datepart("WW",#30/12/2009#,crMonday,crFirstJan1),'##0'))

Other workarounds can be found on the Microsoft website:

http://support.microsoft.com/kb/200299

  

Keywords

KBA , BI-RA-CR , Crystal Reports designer or BusinessViews Manager , How To

Product

SAP Crystal Reports XI R2