can i write a formula to get a week number

Posted on 2011-04-27
Last Modified: 2012-05-11
can i convert a date into a week number? i.e 12/04/2011 is equal to week 15
Question by:Stevepaget
    LVL 18

    Expert Comment

    by:Raheman M. Abdul
    Good source of method to calculate the week number:
    LVL 12

    Expert Comment

    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.
    LVL 12

    Accepted Solution

    Crystal recommends using one of the given formulas if grouping shall be done be weeknumber:

    Use one of the following two formulas:

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


    if datepart("ww",datum,crMonday, crFirstFourDays)=9363 then
    datepart("ww",datum-7,crMonday, crFirstFourDays)+1
    datepart("ww",datum,crMonday, crFirstFourDays);

    Featured Post

    What Is Threat Intelligence?

    Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

    Join & Write a Comment

    Summary: This tutorial covers some basics of pointer, pointer arithmetic and function pointer. What is a pointer: A pointer is a variable which holds an address. This address might be address of another variable/address of devices/address of fu…
    Windows programmers of the C/C++ variety, how many of you realise that since Window 9x Microsoft has been lying to you about what constitutes Unicode ( They will have you believe that Unicode requires you to use…
    Video by: Grant
    The goal of this video is to provide viewers with basic examples to understand and use for-loops in the C programming language.
    The goal of this video is to provide viewers with basic examples to understand how to create, access, and change arrays in the C programming language.

    733 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    25 Experts available now in Live!

    Get 1:1 Help Now