Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Is date for year 2017 already present in your data? do you have any other catch than this??
Can you share more sample data. try below
Load week_st,
week_end,
week
from tableName;
concatenate
Load AddYears(week_st,-1) as week_st,
AddYears(week_end,-1) as week_end,
week
from tableName;
Create a variable vWeekNumber,
vWeekNumber = if(Date(Week_st ) = Date(01/10/2018) and Date(Week_end ) = Date (05/10/2018) , Week1, if(Date(Week_st ) = Date(06/10/2018) and Date(Week_end ) = Date (12/10/2018) , Week2, if(Date(Week_st ) = Date(13/10/2018) and Date(Week_end ) = Date (25/10/2018) , Week3)))
If you already have week in source data then why you want to repeat it??
Sorry but I am not getting your question. Your source data and expected output look same except it's repeatation.
Regards,
Prashant Sangle
Hello Vivek,
I don't see a difference in your data and the requirement. Please rectify.
I assume you have two dates column (Week_st, Week_end) and you need month wise week number as your output.
Use the following code:
T1:
load * Inline
[
Week_st,Week_end
01/10/2018,07/10/2018
08/10/2018,14/10/2018
15/10/2018,21/10/2018
22/10/2018,28/10/2018
];
T2:
load Week_st, Week_end,
'Week'&
if(week(date#(Week_st,'DD/MM/YYYY'))-week(monthstart(date#(Week_st,'DD/MM/YYYY')))+1>1,
week(date#(Week_st,'DD/MM/YYYY'))-week(monthstart(date#(Week_st,'DD/MM/YYYY')))+1,
'1')
as week
Resident T1;
drop Table T1;
Regards,
Amardeep.
Is date for year 2017 already present in your data? do you have any other catch than this??
Can you share more sample data. try below
Load week_st,
week_end,
week
from tableName;
concatenate
Load AddYears(week_st,-1) as week_st,
AddYears(week_end,-1) as week_end,
week
from tableName;
Have you tried that script
It will work. Week is already get added as per current year week.