Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Setting date to first in a month

Hi,

I'm trying to set a variable so it's the first in the current month.

So today 2017-12-06 the variable should read 2017-12-01

I tried:

Let vFirstEveryMonth = Date (Year(Today())+Month(Today())+01,'YYYY-MM-DD hh:mm:ss');

Which returns: 1905-07-22 00:00:00

I assume since it just adds 2017+12+1=2030 which is the day 1905-07-22.


Thankful for any help

Kathrine

1 Solution

Accepted Solutions
richard_chilvers
Specialist
Specialist

.... I just tried MonthsStart(1, TODAY()) and it seems to work

View solution in original post

5 Replies
Anil_Babu_Samineni

May be this?

Let vFirstEveryMonth = Date(MonthStart(MakeDate(Year(Today()),Month(Today()),01)));

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
richard_chilvers
Specialist
Specialist

Hi

Have you tried using the MonthsStart function? It looks like it will do the kind of thing you want, with the correct parameters.

HTH

Anonymous
Not applicable
Author

Thank you!

I found the Monthstart function (waiting for moderation of the question) and it's acctually possible to just write:


Let vFirstEveryMonth= Monthstart (date(today()));

monthsstart - script and chart function ‒ Qlik Sense

Date format etc is allready specified earlier in the code.

richard_chilvers
Specialist
Specialist

.... I just tried MonthsStart(1, TODAY()) and it seems to work

richard_chilvers
Specialist
Specialist

Even better