Dataviewjs date comparisson

Hello, comrads!

I have some problem with dataviewjs (probably because I’m noob in JS)

Start position

Multiple notes with the next yaml structure

---
document_type:  text
document_kind: text
reg_number: text
reg_date: 2023-04-27
synopsys: text
link: url
state: text
todo: text
todo_date: 2023-05-17 23:59
actual_todo_date:  2023-04-01
task: false // bolean
---

I’m creating aggregated table with all notes grouped by “this week”, “next week”, “later” and show only uncompleted.

Next week - Dates between EOW and EOW+7 days
Later - Dates after EOW+7 days

```dataviewjs
let pages = dv.pages('"folder_path"')
dv.header(1, "This week")
dv.table(["Task", "ToDo", "Todo Date", "State", "Document kind", "Registration date", "Synopsys", "Link", "Completed"],
		pages.where(p => p.todo_date <= dv.date("eow")),
		pages.map(p=> [
		dv.func.link(p.file.path, p.file.name.replace('.', '/')),
		p.todo,
		p.todo_date,
		p.state,
		p.document_kind,
		p.reg_date,
		p.synopsys,
		p.link,
		p.task
		],
		))
		

But when I’m adding line pages.where(p.todo_date <= dv.date("eow")) it shows nothing.
Without - the whole notes list.

Question

How should i write correct date comparison in dataviewjs?

dataview date(todo_date) <= date(eow) works well

Without looking too much in it, it seems like your todo_date isn’t actually treated as a date by dataview since it’s missing the T in between the day and time part. Are you sure it’s treated as a date, and not just a string?

I would try either adding the T, or converting that string into a proper date before trying to do any date comparisons.

Maybe the following if you don’t want the T

pages.where(p => date(p.todo_date, "yyyy-MM-dd HH:mm") <= dv.date("eow"))