Calculate date after start based on start date and a week number

Things I have tried

The following code produces the date to one week ahead. I want it to produce dates associated with all values of “week”.

I have tried inserting the key value “week” into the following code. This creates If I could replace “dur(1 week)” with "dur(“week” week) but this produces a dataview error.


TABLE WITHOUT ID
	week, date(2023-01-02) + dur(1 week) as "Date after start"
FROM #course/tft 
SORT week ASC

What I’m trying to do

I am trying to create a table that shows a date calculated from a numeric key value “week”. “week” indicates week from start and I would like the table to show the date corresponding 1, 2 3, … weeks from the start.

A slightly better syntax?

Would the following be acceptable?

---
week: 3
duration: 3 week
---

```dataview
table without id duration, date(2023-01-02) + dur(duration) as "Date after start"
where file.name = this.file.name
```

In other words, type out the entire duration in your field?

With your original syntax

---
week: 3
---

```dataview
table without id week, some, date(2023-01-01) + dur(join([week, " week"], " ")) as date
flatten join([week, " week"], " ") as some
where file.name = this.file.name
```
1 Like

Amazing! Thanks very much for your help.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.