Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
I came across qlik documentation and spot addMonths function. In my case, I have SQL line that I want to translate to qlik logic, and I don't see addDate function in qlik sense. I am wondering if qlik community help me to address my following problem.
Here is the sql line that I want to do same in qlik:
YEAR(LAST_DAY(DATEADD(MONTH,-1,CURRENT_DATE)))
YEAR(LAST_DAY(DATEADD(MONTH,-1,CURRENT_DATE)))
DATEADD('MONTH',-3,LAST_DAY(DATEADD(MONTH,-1,CURRENT_DATE)))
I read date and time function list on qlik help, and I think I might use daystart, dayend function, but I am still not sure how above sql lines can be properly translated to qlik logic. Can anyone in qlik community help me if there is workaround to do this?
Try below exp,
= Year(MonthEnd(AddMonths(CURRENT_DATE,-1)))
= AddMonths(MonthEnd( AddMonths(CURRENT_DATE,-1)),-3)
Thanks,
Sasi
Last Day : MonthEnd(CURRENT_DATE)
Adding Months : AddMonth(CURRENT_DATE,-1)
Thanks Sasi. However, based on your answer, I did this, do you mind to correct me:
in sql code: DATEADD('MONTH',-6,LAST_DAY(DATEADD(MONTH,-1,CURRENT_DATE)))
in qlik, I tried it as : AddMonths('MONTH',-6,MonthEnd(AddMonths(MONTH,-1,Date(Now()))))
I did also like this:
AddMonths(MonthEnd(AddMonths(MONTH,-1,Date(Now()))),'MONTH',-6)
which one would be correct one against sql line that I put? is that correct way to do so? any idea?
HI Alex,
try this
=AddMonths(MonthEnd(AddMonths(today(),-1)),-6)