Jul 13, 2019 03:33 PM
How would you write a date time formula for Beginning of current month to End of current month? The trick is, it’s the current month and the month always changes.
Any Jedi out there?
Jul 13, 2019 09:02 PM
Try this:
First day of month:
DATETIME_PARSE(MONTH(TODAY()) & "/1/" & YEAR(TODAY()), 'M/D/YYYY')
Last day of month:
DATEADD(DATEADD(DATETIME_PARSE(MONTH(TODAY()) & "/1/" & YEAR(TODAY()), 'M/D/YYYY'), 1, 'month'), -1, 'day')
:slightly_smiling_face:
Jul 13, 2019 09:40 PM
You are an Airtable Jedi, it works! Thanks a million!
Jul 13, 2019 11:01 PM
Hi! Need a 2nd part to this formula to make it useful.
I have 3 Fields in my Airtable View.
This is what I would like to do. If deal date equal to or after beginning of month and equal to or before end of month, return 1.
How would you write the formula?
Jul 14, 2019 02:34 AM
Hi,
I have found a formula that solved the challenge that I had. The below formula will return a 1 for any record date from beginning of the current month to the end of the current month.
DATETIME_FORMAT(TODAY(),“YYYYMM”)=DATETIME_FORMAT({Field Date Name},“YYYYMM”)
But now another challenge, does anyone know how to tweak it and make the formula works for PREVIOUS month?
Jul 14, 2019 09:48 AM
The following should return 1 for anything with a {Deal Date} from the previous month :slightly_smiling_face:
IF({Deal Date}, DATETIME_FORMAT(DATEADD({Month Start}, -1, 'month'), 'YYYYMM') = DATETIME_FORMAT({Deal Date}, 'YYYYMM'))
Not sure what your end goal is, but if you’re trying to create a field that will tell you whether the deal was from this month or last month, you can combine the formulas into something like this:
IF({Deal Date}, IF(DATETIME_FORMAT({Deal Date}, 'YYYYMM') = DATETIME_FORMAT({Month Start}, 'YYYYMM'), "This Month", IF(DATETIME_FORMAT(DATEADD({Month Start}, -1, 'month'), 'YYYYMM') = DATETIME_FORMAT({Deal Date}, 'YYYYMM'), "Last Month")))
Hope that helps!
Jul 14, 2019 03:01 PM
You read my mind, it’s exactly what I want to do. You’re a Genius, thanks 2 million!
Jul 14, 2019 04:23 PM
Hi!
I Just tried the formula but something is not right, it doesn’t works. Anything else need to be tweak?
Please see screen shot!
Jul 15, 2019 06:30 AM
Hi,
Just letting you know that your formula works perfectly, I just need to add a {Today Field} and everything works, thank you so much!
IF({Deal Date}, IF(DATETIME_FORMAT({Deal Date}, ‘YYYYMM’) = DATETIME_FORMAT({Today}, ‘YYYYMM’), “This Month”, IF(DATETIME_FORMAT(DATEADD({Today}, -1, ‘month’), ‘YYYYMM’) = DATETIME_FORMAT({Deal Date}, ‘YYYYMM’), “Last Month”)))
Jul 15, 2019 09:50 PM
Hi,
The formula works perfectly but I get some errors cell because the deal date has yet been entered. How can you tweak the formula to make the #ERROR! cells to shows 0?