Forum Discussion
Is it possible to store DateTime.LocalNow() as a scalar variable without creating new column?
Hi there, this problem has had me stuck for a little while.
All I'm trying to do is filter the table so that it keeps rows with a date greater than 7 days old. To do so, I'm simply using the [Date] column from the table and comparing it to DateTime.LocalNow()
Previously, I generated a new column and compared the dates that way:
(note: I recognize both functions reference #"Filter Packet Turned In" but it's just a quick recreation of what I had)
However I'm wondering if there is way to avoid generating a new column and instead store the current day as a variable/function that can be referenced. I tried the process below but got the following error:
Appreciate any help!
Something like this (with your own fields):
= Table.SelectRows(#"previous Step", each Duration.Days( Date.From(DateTime.LocalNow()) - [Date] ) > 7)
4 Replies
- HotChilliCommunity Champion
Something like this (with your own fields):
= Table.SelectRows(#"previous Step", each Duration.Days( Date.From(DateTime.LocalNow()) - [Date] ) > 7)- AnonymousNot applicable
Ok so the Date.From(DateTime.LocalNow()) has to be called in the Table function? It can't be stored as its own seperate variable and be called like I showed in my example?
- HotChilliCommunity Champion
You can declare a variable if you want to:
let thedate = Date.From(DateTime.LocalNow()) in
- AnonymousNot applicable
Alright so the variable 'thedate' needs to be in it's own let-in environment, seperate (or nested) from the main let-in environment of the query?