Cette page a été partiellement traduite par IA. Si vous voyez des erreurs, merci de me les signaler ici.
Retour au tips

Retrieve the quarter from a date

Now, I needed to group the previous database by quarter and year. Instead of doing this manually, I found a formula to achieve this.

To be clear, I didn't create this formula. I found it on Red Gregory’s excellent blog and made a few tweaks.

‍

‍

if(month(dateStart(prop("Start Date"))) < 4, "Q1 - " + year(prop("Start Date")), if(month(dateStart(prop("Start Date"))) < 7, "Q2 - " + year(prop("Start Date")), if(month(dateStart(prop("Start Date"))) < 10, "Q3 - " + year(prop("Start Date")), if(month(dateStart(prop("Start Date"))) < 13, "Q4 - " + year(prop("Start Date")), ""))))

‍

It might seem intimidating, but it's simply the same process repeated four times, once for each quarter. The formula essentially determines the month from the date, and identifies the range it falls within. For instance, if it falls within the 4 to 7 range, it's Q2. I've also included the year by using the simple year() formula.

Deviens le pro de Notion, 5min/semaine

Envie de tout savoir sur Notion ? Rejoins les 15,000+ Notioneers déjà inscrits à la newsletter Notion N°1. Tous les mardis, je t’envoie un petit mail avec 3 astuces pour mieux utiliser Notion, 2 ressources, et 1 tweet de la semaine.

Dernier ajouts