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.
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.
This function returns a value corresponding to a timestamp of the first millisecond of the first day of the month containing date.
montthstart('06/07/2018') will give you 06/01/2018
Monthend ('06/07/2018' will give you 06/30/2018
So this :
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
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
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.
Hi Jesse, if the help helps...
The second parameter adds/substracts months, if you want to substract days you can set the minus after the monthstart function:
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:
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.