Lorentz
I am trying to make a long table 52 weeks of a year so that each week start on monday and end on saturday of the year 2025. The time write in the form dd/mm/yyyy. I know that, the firt year begin 30/12/2024. I tried
```
\documentclass[12pt,a4paper,twoside,openany]{book}
\usepackage[top=2cm, bottom=2cm, left=2cm, right=2cm]{geometry}
\usepackage{fouriernc}
\usepackage[utf8]{vietnam}
\usepackage{pgfcalendar-ext}
\newcommand*{\stripZero}[1]{\if0#1\else#1\fi}
\makeatletter
\newcommand*{\getTwoDaysOfWeek}[9][\the\year]{%
\begingroup
% Julian
\pgfcalendardatetojulian{#1-01-01}{\@tempcnta}
\pgfcalendarjuliantoweekday{\@tempcnta}{\@tempcntb}
\edef\@firstMonday{\the\numexpr\@tempcnta-(\@tempcntb-1)\relax}%
\ifnum\@tempcntb=1\relax
\edef\@firstMonday{\@tempcnta}%
\fi
\edef\@dateStartWeek{\the\numexpr\@firstMonday+(#2-1)*7\relax}%
\edef\@temp{\endgroup%
\noexpand\pgfcalendarjuliantodate
{\@dateStartWeek}{\noexpand#4}{\noexpand#5}{\noexpand#6}%
\noexpand\pgfcalendarjuliantodate
{\the\numexpr\@dateStartWeek+#3\relax}{\noexpand#7}{\noexpand#8}{\noexpand#9}}%
\@temp
}
\makeatother
% dd/mm/yy
\newcommand*{\weekCell}[2][\the\year]{
Week #2:\\
(\getTwoDaysOfWeek[#1]{#2}{5}{\y}{\m}{\d}{\Y}{\M}{\D}
\stripZero\d/\stripZero\m/\y $-$ \stripZero\D/\stripZero\M/\Y)
}
\usepackage{pgffor}
\usepackage{booktabs}
\begin{document}
\begin{tabular}{cll}
\toprule
Time & Work & Note \\\midrule
\weekCell[2025]{1} & Content 1 & Note 1 \\ % week 1
\weekCell[2025]{2} & Content 1 & Note 1 \\ % week 2
\weekCell[2025]{3} & Content 1 & Note 1 \\ % week 3
\weekCell[2025]{4} & Content 1 & Note 1 \\ % week 4
\weekCell[2025]{5} & Content 1 & Note 1 \\ % week 5
\weekCell[2025]{6} & Content 1 & Note 1 \\ % week 6
\weekCell[2025]{7} & Content 1 & Note 1 \\ % week 7
\dots & \dots & \dots \\
\bottomrule
\end{tabular}
\end{document}
```
The result begin at 31/12/2024. It must be 30/12/2024.
![image.png](/image?hash=ee20df9abe958160faf5f9e0dcff9b730b68008d4275949bbf6a8e0e4367a828)
How can I get the correct result?
If I want to build weeks from the september of 2025 to June of 2026. How can I make the code?
Top Answer
JohnPaul
My code
```
\documentclass[12pt,a4paper]{article}
\usepackage[top=2cm, bottom=2cm, left=2cm, right=2cm]{geometry}
\usepackage{fouriernc}
\usepackage{enumitem}
\usepackage{pifont}
\usepackage{amssymb}
\usepackage{ninecolors}
\usepackage{tabularray}
\UseTblrLibrary{varwidth}
\usepackage{esvect}
\UseTblrLibrary{amsmath, booktabs, counter,
diagbox, siunitx, varwidth}
\usepackage{pgfcalendar-ext}
\newcommand*{\stripZero}[1]{\if0#1\else#1\fi}
% Tính ngày bắt đầu và kết thúc tuần
\makeatletter
\newcommand*{\getTwoDaysOfWeek}[9][\the\year]{%
\begingroup
\pgfcalendardatetojulian{#1-12-10}{\@tempcnta}% Julian ngày 01/01
\pgfcalendarjuliantoweekday{\@tempcnta}{\@tempcntb}% Thứ của 01/01
\edef\@dateStartWeek{\the\numexpr\@tempcnta-\@tempcntb+1+#2*7-8\relax}% Adjusted to start from 30/12
\edef\@temp{\endgroup%
\noexpand\pgfcalendarjuliantodate
{\@dateStartWeek}{\noexpand#4}{\noexpand#5}{\noexpand#6}%
\noexpand\pgfcalendarjuliantodate
{\the\numexpr\@dateStartWeek+#3\relax}{\noexpand#7}{\noexpand#8}{\noexpand#9}}%
\@temp
}
\makeatother
\newcommand*{\weekCell}[2][\the\year]{%
Week #2:\\
(\getTwoDaysOfWeek[#1]{#2}{5}{\y}{\m}{\d}{\Y}{\M}{\D}%
\stripZero\d/\stripZero\m/\y \,$-$ \stripZero\D/\stripZero\M/\Y)
}
\usepackage{pgffor}
\begin{document}
\begin{longtblr}[caption={Something}]{colspec={Q[c] Q[l] Q[c]},hlines, vlines,measure=vbox,stretch=-1,row{1}={bg=gray!30}}
Column 1 & Column 2 & Column 3 \\
\weekCell{4} & Content 2 & Note 2 \\
\weekCell{5} & Content 1 & Note 1 \\
\weekCell{6} & Content 2 & Note 2 \\
\weekCell{7} & Content 1 & Note 1 \\
\weekCell{8} & Content 2 & Note 2 \\
\weekCell{9} & Content 1 & Note 1 \\
\weekCell{10} & Content 2 & Note 2 \\
\weekCell{11} & Content 1 & Note 1 \\
\weekCell{12} & Content 2 & Note 2 \\
\weekCell{13} & Content 1 & Note 1 \\
\weekCell{14} & Content 2 & Note 2 \\
\weekCell{15} & Content 1 & Note 1 \\
\weekCell{16} & Content 2 & Note 2 \\
\weekCell{17} & Content 1 & Note 1 \\
\weekCell{18} & Content & Note 2 \\
\weekCell{19} & Content 1 & Note 1 \\
\weekCell{20} & Content 2 & Note 2 \\
\weekCell{21} & Content 1 & Note 1 \\
\weekCell{22} & Content 2 & Note 2 \\
\weekCell{23} & Content 1 & Note 1 \\
\weekCell{24} & Content 2 & Note 2 \\
\weekCell{25} & Content 1 & Note 1 \\
\weekCell{26} & Content 2 & Note 2 \\
\weekCell{27} & Content 1 & Note 1 \\
\weekCell{28} & Content 2 & Note 2 \\
\weekCell{29} & Content 1 & Note 1 \\
\weekCell{30} & Content 2 & Note 2 \\
\weekCell{31} & Content 1 & Note 1 \\
\weekCell{32} & Content 2 & Note 2 \\
\weekCell{33} & Content 1 & Note 1 \\
\weekCell{34} & Content 2 & Note 2 \\
\weekCell{35} & Content 2 & Note 2 \\
\weekCell{36} & Content 2 & Note 2 \\
\weekCell{37} & Content 1 & Note 1 \\
\end{longtblr}
\end{document}
```
![image.png](/image?hash=c683b1fc143cfb78464b882e6841bc9bc9d240491002353891b12f62a711e29a)