can i write a formula to get a week number

can i convert a date into a week number? i.e 12/04/2011 is equal to week 15
StevepagetAsked:
Who is Participating?
 
HugoHiaslCommented:
Crystal recommends using one of the given formulas if grouping shall be done be weeknumber:

Workaround:
Use one of the following two formulas:
Formula1:

if datepart('ww',{date_table.date},crMonday,crFirstFo urDays) >53
then datepart('ww',{date_table.date}-5) else datepart('ww',{date_table.date},crMonday,crFirstFo urDays);

Forumula2:

if datepart("ww",datum,crMonday, crFirstFourDays)=9363 then
datepart("ww",datum-7,crMonday, crFirstFourDays)+1
else
datepart("ww",datum,crMonday, crFirstFourDays);
0
 
Raheman M. AbdulSenior Infrastructure Support Analyst & Systems DeveloperCommented:
Good source of method to calculate the week number: http://www.merlyn.demon.co.uk/weekcalc.htm
0
 
HugoHiaslCommented:
You can use the  built-in function

DATEPART("ww", {SALES.SALEDATE}, crSunday)


But be carefully. It has problems if the date is in the new year but belongs to week 53 of the old year.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.