← Retour au Tableau de Bord
Hub Développeur
Extraits prêts à l'emploi pour vos analyses. Standardisez vos calculs épidémiologiques.
R Langage R
Nous recommandons lubridate package pour une manipulation robuste des dates.
Norme CDC (MMWR)
library(lubridate)
# Get current Epi Week (CDC)
epiweek(Sys.Date())
# For a specific date
epiweek(as.Date("2024-01-01")) Norme ISO 8601
library(lubridate)
# Get current ISO Week
isoweek(Sys.Date()) Python Python
Le package epiweeks est la solution la plus complète pour la norme CDC.
Norme CDC (MMWR)
# pip install epiweeks
from epiweeks import Week, Year
from datetime import date
# Current week
week = Week.fromdate(date.today())
print(f"EW {week.week} of {week.year}")
# Iterate over weeks
for week in Year(2024).iterweeks():
print(week.startdate(), week.enddate()) SQL SQL (PostgreSQL)
Norme ISO 8601
-- Return week in 'IYYY-IW' format (e.g. 2024-01)
SELECT TO_CHAR(CURRENT_DATE, 'IYYY-IW');
-- Week number only
SELECT EXTRACT('week' FROM CURRENT_DATE); Excel Excel / Google Sheets
Norme ISO 8601
=ISOWEEKNUM(A1) Utilisant la fonction standard ISOWEEKNUM.