Power Query Date Range - Between Two Dates

jws

Board Regular
Joined
Jan 10, 2008
Messages
69
Hello,

I am having trouble with logic on this on a function where I am trying to create a rolling history file with a rolling date range.

Basically I am taking today's date and my goal is:
1) Pull data 60 days ago (which works) - but where my problem is, I am trying to add an "AND" statement that limits to Today - 40 days)

This works
= Table.SelectRows(#"Changed Type", each [DATE] > Date.AddDays(Date.From(DateTime.LocalNow()),-60))

Today is June 1st (return data from 4/2/20 thru 4/22/20)

4/2/20 = (-60 days from today)
4/22/20 = (-40 days from today)

I don't want to use actual dates since this will be a rolling file. If this is unclear let me know, thanks for reading.
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
Try:

= Table.SelectRows(#"Changed Type", each ([DATE] >= Date.AddDays(DateTime.Date(DateTime.LocalNow()),-60) and [DATE] <= Date.AddDays(DateTime.Date(DateTime.LocalNow()),-40)))
 
  • Like
Reactions: jws
Upvote 0

Forum statistics

Threads
1,215,758
Messages
6,126,713
Members
449,332
Latest member
nokoloina

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top