Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Want to see what's currently in public preview? We've pulled it all together in one place. Check it out here
cancel
Showing results for 
Search instead for 
Did you mean: 
Nagaraju_KCS
Specialist III
Specialist III

Date Functions

Hi All,

This is my Calendar....

I want to create one field WeekNumber (start should be 1,2,3,4,5,6)

Let vMinDate=Num(MakeDate(2015,01,01));

Let vMaxDate=Num(MonthEnd(Today()));

Load

              $(vMinDate) AS Date,

              week($(vMinDate)) As Week,

              Year($(vMinDate)) As Year,

              Month($(vMinDate)) As Month,

              Day($(vMinDate)) As Day,            

                Week(weekstart($(vMinDate))) & '-' & WeekYear($(vMinDate)) as WeekYear,

              WeekDay($(vMinDate)) as WeekDay    

Autogenerate (1)

While ($(vMinDate)+IterNo())<$(vMaxDate);


Actually i have created weeknumber, but year=2016 and Month=Feb.. it showing starts from 2,3,4,5,6

But my requirement.. it should be 1, 2,3, 4, 5


Whatever if i am click any month it should start from 1,2,3,4,5,6


Thanks in Advance.....

Labels (1)
11 Replies
Nagaraju_KCS
Specialist III
Specialist III
Author

Please anyone can help me....

Not applicable

Hi

Add this at the top to your script an make sure det dateformat is the same:

SET DateFormat='YYYY.MM.DD';

SET vCal_FD = 0; // First Day of the week {0=Mon, 1=Tue, ... , 6=Sun}
SET vCal_BW = 1; // Broken Weeks allowed {0=No, 1=Yes}
SET vCal_RD = 4; // Reference day = This day in Jan defines week one {1..7}

//and this in the tabelscript that you are uploading

  Div( your date field here - WeekStart( Date( YearStart( If( $(vCal_BW), your date field here, Date( WeekStart( your date field here, 1, $(vCal_FD) ) - $(vCal_RD) ) )) + $(vCal_RD) - 1), 0, $(vCal_FD) ) + 7, 7 ) as Week,

   Year( Date( YearStart( If( $(vCal_BW), your date field here , Date( WeekStart(your date field here , 1, $(vCal_FD) ) - $(vCal_RD) ) )) + $(vCal_RD) - 1) ) as Year,

   Month( Date( MonthStart( If( $(vCal_BW), your date field here , Date( WeekStart( your date field here , 1, $(vCal_FD) ) - $(vCal_RD) ) )) + $(vCal_RD) - 1) ) as Month,