Reply To: Calculating days since start of year

#10485
Jacob Sagrans
Participant

I realized it might be useful to see the formulas for more generic attribute names, so here goes:If you have 3 columns/attributed titled “Day”, “Month”, and “Year”, use this formula (make sure month is indicated as a number like 12, NOT “December”, and for Year, give 4 digits, for example 2024, NOT 24):Day +if(Month> 1, 31, 0) +if(Month> 2, 28, 0) +if(Month> 3, 31, 0) +if(Month> 4, 30, 0) +if(Month> 5, 31, 0) +if(Month> 6, 30, 0) +if(Month> 7, 31, 0) +if(Month> 8, 31, 0) +if(Month> 9, 31, 0) +if(Month> 10, 31, 0) +if(Month> 11, 30, 0) +if(frac(Year/ 4) = 0 & Year> -47 & frac(Month/ 100) != 0 or frac(Month/ 400) = 0, 1, 0)If you have 1 column of date attribute type titled “Date”, use this formula:dayOfMonth(Date) +if(month(Date) > 1, 31, 0) +if(month(Date) > 2, 28, 0) +if(month(Date) > 3, 31,0) +if(month(Date) > 4, 30, 0) +if(month(Date) > 5, 31, 0) +if(month(Date) > 6, 30, 0) +if(month(Date) > 7, 31, 0) +if(month(Date) > 8, 31, 0) +if(month(Date) > 9, 31, 0) +if(month(Date) > 10, 31, 0) +if(month(Date) > 11, 30, 0) +if(year(Date) < -46, 0,if(frac(year(Date) / 400) = 0, 1,if(frac(year(Date) / 100) = 0, 0,if(frac(year(Date) / 4) = 0, 1, 0))))