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: 
taylor_jesse
Creator
Creator

MonthStart(today(), ) and Monthend(today(), )

Can someone please help me understand clearly what the monthstart() and the MonthEnd() function means in plain English.

Also what if instead of month start I want to use days what function will that be.

for instance what will monthstart(today(),-5). and  monthend(today(),-2). represent. My confusion is what day exactly or how does it calculate the month with the integer values.

Thank you

10 Replies
sunny_talwar

MonthStart is a function which gives the beginning date for any given date. For example, if you do MonthStart(Today()), it will give you June 1st.

MonthEnd gives the last day of the month, the only thing to note is that it gives the last day to the last second. So MonthEnd(Today()) will give you June 30th 11:59:59 pm. To get just the date, you can use Floor() function. Floor(MonthEnd(Today()).

MonthStart(Today(), -5) will take you 5 months back from today. So, it will give you Jan 1st 2018.

brunobertels
Master
Master

Hi Jesse

This function returns a value corresponding to a timestamp of the first millisecond of the first day of the month containing date.


Example :

montthstart('06/07/2018') will give you 06/01/2018

Monthend ('06/07/2018' will give you 06/30/2018


So this :

monthstart(today(),-5)


decompose the mesure :

Today() will give you 06/07/2018

Monthstart(Today() ) will give you 06/01/2018

monthstart(today(),-5) will give you five month before this current month so 6 - 5 = 1 as january

then 01/01/2018


monthend(today(),-2) will give you 04/30/2018

last day of june minus 2 month = 04/30/2018


have a look a Qlik help page for further details


Bruno

petter
Partner - Champion III
Partner - Champion III

MonthStart( <a-date> , <months-in-the-future> )

Will take the month of the first parameter and return the 1st of that month if there is no second parameter given.

If there is a second parameter it will add that to the month before it returns the result. So you can calculate previous months (negative numbers) and future months (positive numbers).

So if the current date is 15th of January 2018 then this:

MonthStart( Today(1) , -1 ) will return the 1st of December 2017.

MonthStart( Today() ) will return the 1st of January 2018

Similarly the MonthEnd will return the last day of any given month.

MonthEnd( Today() ) will return the 31st of January 2018.

MonthEnd( Today() , 1) will return the 28th of February 2018.

MonthEnd( Today(), -24 ) will return the 29th of February 2016.

rubenmarin

Hi Jesse, if the help helps...

https://help.qlik.com/en-US/sense/April2018/Subsystems/Hub/Content/Scripting/DateAndTimeFunctions/mo...

https://help.qlik.com/en-US/sense/April2018/Subsystems/Hub/Content/Scripting/DateAndTimeFunctions/mo...

The second parameter adds/substracts months, if you want to substract days you can set the minus after the monthstart function:

monthstart(today())-5


A date is an integer number with day as base unit, so -5 substracts 5 days, +0.5 adds 12 hours.


About dates and calendars:

How to use - Master-Calendar and Date-Values

rubenmarin

Weird that this time I have remembered to refresh before posting and still didn't see any answer, after posting some answers shows, some from minutes ago.

taylor_jesse
Creator
Creator
Author

Thanks a lot Sunny I thought month start today pretty much just consider the start of the mont as today?

Thanks a lot

taylor_jesse
Creator
Creator
Author

Thank you for the explanation

taylor_jesse
Creator
Creator
Author

Thank you Sir

sunny_talwar

Hahahaha no, that's not what it does