How can I count up datetime in a loop over several pages in weekly steps?

Hey guys. I was searching for a solution to a problem i can’t wrap my head around it even after looking at similar problems discussed in this forum. I’m trying to do a journal with 1 week on a page. The pages get created but the date is not changing. So i get 52 pages with the same dates. If you could help me with my problem i’d really appreciate it :slight_smile:

//Variables
#let date = datetime(day: 11, month: 8, year: 2025)
#let day = duration(days: 1)

//Begin Agenda

#for i in range(0, 52) {
  [
  #align(center)[*KW:* #date.display("[week_number]")]
  #table(
  columns: 18.9cm,
  align: (left),
  table.cell(fill: gray.lighten(80%))[#custom-date-format(date, "Day, dD. Month", "de")],[#caro(9)],
  table.cell(fill: gray.lighten(80%))[#custom-date-format(date + day, "Day, dD. Month", "de")], [#caro(9)],
  table.cell(fill: gray.lighten(80%))[#custom-date-format(date + 2*day, "Day, dD. Month", "de")], [#caro(9)],
  table.cell(fill: gray.lighten(80%))[#custom-date-format(date + 3*day, "Day, dD. Month", "de")], [#caro(9)],
  table.cell(fill: gray.lighten(80%))[#custom-date-format(date + 4*day, "Day, dD. Month", "de")],[#caro(9)],
  )
  #pagebreak()
  #let date = date + duration(weeks: 1)
  ]
}

Hello @truezzL and welcome!

Please make sure to post a reproducible and minimal example, so that we can help you to the best of our abilities!

Your problem lies in how you update your date. See the example below where you obtain

#let date = datetime(day: 11, month: 8, year: 2025)
#date

#for i in range(0, 2) {
  let date = date + duration(weeks: 1)
  [#date#linebreak()]
}

The “let” statement defines a new variable. So, make sure to just write date = .... See below

#let date = datetime(day: 11, month: 8, year: 2025)

#for i in range(0, 3) {
  date = date + duration(weeks: 1)
  [#date#linebreak()]
}

Thank you so much for your help!

1 Like