Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Fixed values for startofmonth/endofmonth

Thomas Fredrik Bergmann November 6, 2018

Hiya!

 

I'm doing a query with created >= "2018-10-01 00:00" AND created <= "2018-1-01 00:00", that I potentially will manually change every month.

How do I instead use startOfMonth() and endOfMonth() if I i.e. want to limit the results to August month? startOfMonth(8) I guess will start from the 8. month from now, as I guess it's relative values?

3 answers

1 accepted

0 votes
Answer accepted
Alexey Matveev
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 6, 2018

Hello,

You can get 01 August by this one

startOfYear(212d)

Alexey Matveev
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 6, 2018

m means minutes. There is no shortcut for months.

212d gives you August 1 in the current year. If it does not give you August 1 in the next year (leap year), then you should change the filter. But you will do it only once in 4 years.

Like ogawa tatsumi likes this
2 votes
Vinu
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 6, 2018

Hi @Thomas Fredrik Bergmann

If calculating the number of days might be difficult for you. You can mention the month based on your current month.

For Eg: If I say my present month is September and I want the issues from august, you can query the function to be startOfMonth(-1) which denotes the previous month.

The calculation is always from the present month, which means if I have startOfMonth(-2), it means October if my present month in December and startOfMonth(2) would mean the seond month down the line.

0 votes
Thomas Fredrik Bergmann November 6, 2018

Thanks for the answers. However, I need it of course to be a fixed month. I can't have it tomorrow be a different result, so I have to get away from relative values all together. It would seem that others need this too, so there probably is another way of doing it, if startOfMonth() only takes relative values.

Alexey Matveev
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 6, 2018

If you use startOfYear(212d) it will be always August first of the current year.

Thomas Fredrik Bergmann November 6, 2018

Ah, okay got ya, so I missed the d behind the integer. In that syntax, maybe startOfYear(8m) maybe works?

Thomas Fredrik Bergmann November 6, 2018

Oh, it didn't. I guess it's not 212d in leap years? 

Vinu
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 6, 2018

August 1 is the 213th day of the year (214th in leap years) in the Gregorian calendar. 

Suggest an answer

Log in or Sign up to answer