Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi,
I wanted to create another field which is will define as number of the Week for the Date. The number of the week should will start from 1 and will end with 4 or 5 for the particular month. Please let me know the expression.
Week Number | RangeDate |
---|---|
1 | 1 - 6 Nov 2011 |
2 | 7 - 13 Nov 2011 |
3 | 14 - 20 Nov 2011 |
4 | 21 - 27 Nov 2011 |
5 | 28 - 30 Nov 2011 |
1 | 1 - 4 Dec 2011 |
2 | 5 - 11 Dec 2011 |
3 | 12 - 18 Dec 2011 |
4 | 19 - 25 Dec 2011 |
5 | 26 - 31 Dec 2011 |
Try something like
LOAD *
,if(month(weekend(Date))= month(Date),div(WeekendDay,7),div(day(Weekend(Date,-1)),7)+1)+1 as Weeknumber
;
LOAD *
,day(WeekEnd(Date)) as WeekendDay
,day(Date) as DayOfMonth
,weekday(Date) as Weekday
;
LOAD
date(makedate(2011,1,1)+recno()-1) as Date
AUTOGENERATE 365
;
Try something like
LOAD *
,if(month(weekend(Date))= month(Date),div(WeekendDay,7),div(day(Weekend(Date,-1)),7)+1)+1 as Weeknumber
;
LOAD *
,day(WeekEnd(Date)) as WeekendDay
,day(Date) as DayOfMonth
,weekday(Date) as Weekday
;
LOAD
date(makedate(2011,1,1)+recno()-1) as Date
AUTOGENERATE 365
;
Hi,
In that case if Weekend is 07th date of everymonth. Then it will shows 01st to 6th date as 2nd week which is wrong. It should show 1st week. Please help on this.
Example : May Month Weekstart from 01-May-2011 and ends on 07-May-2011. So this is weekno 1 and 08-May-2011 to 14-May-2011 is 2nd week but here it is showing wrong. Please check and revert
Regards,
Sakthivel.S
Hi
This Works fine.
if((week(Date) - week(monthstart(Date)) + 1)<1,1,(week(Date) - week(monthstart(Date)) + 1))
Regards,
Sakthivel.S