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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

error in makeweekdate function.

I use Qlikview 7.

The makewekdate function

date(makeweekdate(year('2010-01-03'),Week('2010-01-03')),'YYYY-MM-DD')

gives 2011-01-03 instead fo 2009-12-28. i.e one year ahead. or am i making a big blunder?

Thanks,

Mmahan

4 Replies
johnw
Champion III
Champion III

When you get unexpected results, you can break the problem into pieces and interpret what you see:

  1. year('2010-01-03') = 2010
  2. week('2010-01-03') = 53 (2010-01-03 is the last day of the last week of the PREVIOUS year, 2009)
  3. makeweekdate(2010,53) = 2011-01-03 (only 52 weeks in 2010, so week 53 of 2010 is interpreted as week 1 of 2011)

Are you actually trying to accomplish something with this expression, or just fiddling with date functions?

Not applicable
Author

Thanks for the explanation. Actually I am making a time dimension link with actual values from the DB date table column.. I take all the distinct created-on column values from my table and use those values to create the week field which is linked to my time dimension. So when there is this date coming from one of the distinct table values the makeweekdate converts it to the above one as i explained. So in my combo box drop down it shows the week date as 2011-01-03 for the table date 2010-01-03. Although it doesn't effect my display values and the application functions OK it just looks Odd. I have to write a if condition for grouping this date in 2009-12-28 week. i.e I am hard coding my script for this test. I don't want to hard code my script in general.

Thanks for your explanation.

johnw
Champion III
Champion III

So you're just trying to get the first day of the week? That's the weekstart() function if so.

Not applicable
Author

That's correct. Thanks.