Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2367
  • Last Modified:

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
0
Stevepaget
Asked:
Stevepaget
  • 2
1 Solution
 
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
 
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

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now