Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi Experts,
I have one column data like ....
Day
01 mar
02mar
03 mar
04mar
05 mar
06 mar
07 mar
08 mar
09 mar
10 mar
11 mar
12 mar
13 mar
14 mar
15 mar
16 mar...........................
Here i need week numbers.
Try it,
Test:
Load *,
Left(Day,2) as D,
right(Day,3) as M,
year(Today()) as Y
Inline [
Day
01 mar
02mar
03 mar
04mar
05 mar
06 mar
07 mar
08 mar
09 mar
10 mar
11 mar
12 mar
13 mar
14 mar
15 mar
];
Load *,
Makedate(Y, Month(Date#(M, 'MMM')), D) as Date1
Resident Test;
Drop Table Test;
in Expression: Week(Date1)
Convert the data to actual dates. Once done, use the week() function to generate an extra field that contains the week number.
To convert to date, use the date#() function.
and what about the year?
Hi Marco Wedel,
In my data year is not there.
Hi,
Once you are having DATE field in Data model , simply write script below to get Month, Week , Year out of it.
LOAD
DATE,
Year(DATE) as YEAR,
Month(DATE) as MONTH,
Week(DATE) as WEEK,
WeekDay(DATE) as WEEKDAY,
Day(DATE) as DAY,
From
.....
Thanks,
AS
Hi AS,
I don't have DATE field . I have only Day field
Try it,
Test:
Load *,
Left(Day,2) as D,
right(Day,3) as M,
year(Today()) as Y
Inline [
Day
01 mar
02mar
03 mar
04mar
05 mar
06 mar
07 mar
08 mar
09 mar
10 mar
11 mar
12 mar
13 mar
14 mar
15 mar
];
Load *,
Makedate(Y, Month(Date#(M, 'MMM')), D) as Date1
Resident Test;
Drop Table Test;
in Expression: Week(Date1)
Or by using this You can make script more simple,
Test:
Load *,
Makedate(year(Today()), Month(Date#(right(Day,3), 'MMM')), Left(Day,2)) as Date1
Inline [
Day
01 mar
02mar
03 mar
04mar
05 mar
06 mar
07 mar
08 mar
09 mar
10 mar
11 mar
12 mar
13 mar
14 mar
15 mar
];
Cheers
Try this!
Days:
LOAD * INLINE [
Day
3/1/2015
3/2/2015
3/3/2015
3/4/2015
3/5/2015
3/6/2015
3/7/2015
3/8/2015
3/9/2015
3/10/2015
3/11/2015
];
Weeks:
LOAD
Week(Day) AS Week,
WeekName(Day) AS WeekName
Resident Days;