Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Problem with week start

Hi all,

I am trying to create a calendar having each week start on Thursday. I have read and applied various ideas from many posts but I still have a problem; the week number. In my case, The first week of the year starts from the first day of the year BUT it lasts until the first Wednesday of the year. For example, for year 2013 we shall have:

DateDayWeek Number
1/1/2013Tuesday1
2/1/2013Wednesday1
3/1/2013Thursday2
4/1/2013Friday2
5/1/2013Saturday2
6/1/2013Sunday2
7/1/2013Monday2
8/1/2013Tuesday2
9/1/2013Wednesday2
10/1/2013Thursday3
......

Any ideas of how I achieve that?

Thanking you in advance,

Greg

1 Solution

Accepted Solutions
hic
Former Employee
Former Employee

Not if you change the variable that defines the minimum number of days in week one to 1:

Set vMinDaysInWeek      = 1; // Minimal number of days in week no 1. (For the U.S. = 1)


HIC

View solution in original post

7 Replies
hic
Former Employee
Former Employee

There is a script that does this in one of my blog posts: Ancient Gods and Modern Days

HIC

kaushiknsolanki
Partner Ambassador/MVP
Partner Ambassador/MVP

Hi,

     Try this.

let vMinDate = num(MakeDate(2012,01,01));

Let vMaxDate = num(MakeDate(2012,12,31));

Load Date($(vMinDate) + RowNo() -1) as Date,

  Week(Date($(vMinDate) + RowNo() -1)) as Week,

  WeekDay(Date($(vMinDate) + RowNo() -1)) as WeekDay,

  num(WeekDay(Date($(vMinDate) + RowNo() -1))) as WeekDayNum,

  week(WeekStart(Date($(vMinDate) + RowNo() -1),0,3)) as NewWeek

AutoGenerate 1

While Date($(vMinDate) + RowNo() -1) < Date($(vMaxDate));

This might not what you want, but i am sure this will help you to understand and then you can develop by our own.

Regards,

Kaushik Solanki

Please remember to hit the 'Like' button and for helpful answers and resolutions, click on the 'Accept As Solution' button. Cheers!
Not applicable
Author

Thank you

I have extensively used this exact post.

I think the problem is that the duration of week one is not static (7 days from the day I have defined as the first day of week).


In your example, week 1 would start from 3/1/2013 and the previous days will be week 52.

hic
Former Employee
Former Employee

Not if you change the variable that defines the minimum number of days in week one to 1:

Set vMinDaysInWeek      = 1; // Minimal number of days in week no 1. (For the U.S. = 1)


HIC

jagan
Luminary Alumni
Luminary Alumni


Hi,

Try lunarweek(),

=SubField(LunarWeekName(DateDimension), '/', 2)

Hope this helps you.

Regards,

Jagan.

Not applicable
Author

Hi,

Check whether below script helps you.

LOAD

Date,

Month(Date) as Month,

WeekDay(Date) as Day,

Num(WeekDay(Date)) as WkDay,

If((Day(Date)=1) and (Month(Date)=1),1,

  If(Num(WeekDay(Date))=3,Peek('WeekNo')+1,Peek('WeekNo'))) as WeekNo;

Resident YourTable;

One thing here is your Date field should have value starts from 1st January.

regards

GowriShankar

Not applicable
Author

Thank you, you are right, I missed sth on the script.

Kind Regards,

Greg