Skip to content

feat: add 'date.now' function for current timestamp support#5721

Open
sunyeongchoi wants to merge 9 commits intoPRQL:mainfrom
sunyeongchoi:feature/now
Open

feat: add 'date.now' function for current timestamp support#5721
sunyeongchoi wants to merge 9 commits intoPRQL:mainfrom
sunyeongchoi:feature/now

Conversation

@sunyeongchoi
Copy link
Contributor

@sunyeongchoi sunyeongchoi commented Mar 20, 2026

Closes #5720

Add date.now function for current timestamp

Adds a date.now function to the PRQL standard library that returns the current timestamp, enabling time-based filtering and comparisons.

from events
filter event_time < date.now

@sunyeongchoi
Copy link
Contributor Author

sunyeongchoi commented Mar 20, 2026

I’ve enabled support for this syntax: filter event_time < now.
But I’m wondering, which one aligns better with our project’s current style, now or date.now?

@max-sixty
Copy link
Member

yes, date.now would be much better, thank you for suggesting!

@sunyeongchoi sunyeongchoi changed the title feat: add 'now' function for current timestamp support feat: add 'date.now' function for current timestamp support Mar 24, 2026
@@ -1,7 +1,5 @@
# Date functions

These are all the functions defined in the `date` module:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we restore this? or was there a reason to remove?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh It's my mistake. I'll restore this. Thank you.

gross_salary = (salary + payroll_tax | as int),
gross_salary_rounded = (gross_salary | math.round 0),
time = s"NOW()", # an s-string, given no `now` function exists in PRQL
time = date.now, # current timestamp; or use s"NOW()" for a dialect-specific s-string
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature Request] Support native date.now function in standard library to reduce S-string usage

2 participants