Week | Quarter | Year Calculation using Apex | Aura
Calculation of current week number, quarter number, and year. Below is an apex code to calculate those details. Week Number : Integer daysSince1900_01_07 = Date.newInstance(1900, 1, 7).daysBetween(system.today()); Integer dayNumber = Math.mod(daysSince1900_01_07, 7) + 1; Date dateForYear = system.today().addDays(Math.mod(8 - dayNumber, 7) - 3); Integer yearNum = dateForYear.year(); Date year_01_01 = Date.newInstance(yearNum, 1, 1); Integer weekNum = (Integer)Math.floor((year_01_01.daysBetween(system.today()) + Math.mod((Math.mod(Date.newInstance(1900, 1, 7).daysBetween(year_01_01), 7) + 1) + 1, 7) - 3) / 7 + 1); System.debug('Current Week Number is :::'+wee...