7 Replies Latest reply: Nov 11, 2014 6:42 PM by Marco Wedel

# week

hi guys,

i have a year <<2009>>, and i want to display all the weeks in this year,

• ###### Re: week

Let vMinDate= num(DayStart(makeDate(2009)))

let vMaxDate= num(DAyStart(makeDate(2009,12,31)))

tempCalendar:

LOAD \$(vMinDate) + RowNo() -1 as DateNumber

AutoGenerate \$(vMaxDate) - \$(vMinDate) + 1;

MasterCalendar:

Month(date(DateNumber)) as Month,

Year(date(DateNumber)) as Year,

Week(Date(DateNumber)) as Week,

'Q' & ceil(Month(Date(DateNumber))/3) as Quarter

Resident tempCalendar;

drop Table tempCalendar;

• ###### Re: week

use Week() function:

=Week(yourdatefield)

will return you the number of week within your year.

Marc.

• ###### Re: week

Hi,

Try to load Min and max YearStart and Year End of 2009 and then create master calendar for week fields.

Raw:

[ Year

2009 ];

Dates:

NUM(YearStart(MakeDate(2009))) as YearStartDate,

NUM(YearEnd(MakeDate(2009))) as YearEndDate

Resident Raw;

Let vMinDate = peek('YearStartDate',0,'Dates');

let vMaxDate = peek('YearEndDate',0,'Dates');

tempCal:

LOAD \$(vMinDate) + RowNo() -1 as TempDate

AutoGenerate \$(vMaxDate) - \$(vMinDate) + 1;

MasterCalendar:

TempDate ,

Date(TempDate) as  Date,

Month(date(TempDate)) as Month,

Year(date(TempDate)) as Year,

Week(Date(TempDate)) as Week

Resident tempCal;

DROP Table tempCal;

DROP Table Dates;

DROP Table Raw;

And fields you get like

Regards

Anand

• ###### Re: week

this is a more elegant format of my answer

• ###### Re: week

Hi Youssuf,

Yes because your requirement is you have only Year field which has only 2009 means we have requires weeks of 2009 from 01/01/2009 to 31/12/2009. But using only Week(Datefield) is worked when you have date field right so in my post i requires Year start and Year End of the 2009 as you can see the load script for this.

Regards

Anand

• ###### Re: Re: week

Hi,

maybe this version helps also:

```LET vYear = 2009;

MasterCalendar:
Month(Date) as Month,
Year(Date) as Year,
Week(Date) as Week;
AutoGenerate 1
While Year(MakeDate(\$(vYear))+IterNo()-1)=\$(vYear);
```

regards

Marco

• ###### Re: week

Hi,

just one more:

```LET vYear = 2009;

tabWeekCalendar:
Week(WeekStart) as Week,
WeekName(WeekStart) as WeekName,
WeekYear(WeekStart) as WeekYear;
AutoGenerate 1
While WeekYear(MakeWeekDate(\$(vYear),IterNo()))<=\$(vYear);
```

hope this helps

regards

Marco