Dynamic Date Range in MS Query using DATEADD

john lilleystone • March 1, 2020

Dynamically shift your dates in Excel and MS Query using DATEADD.

In this screen shot you can see we've explicitly set the date range in MS Query to extract data into Excel. However, this particular report is just a monthly report that I run each month and I don't want to have to edit this date range each time.

In the screen shot below, if we use this syntax, it will dynamically shift the time frame for us when we refresh the data.

In English this is saying look at the months element of the Invoice Date and go back 12, look at today’s date and select everything in between. Substitute 12 for whatever time period you want to go back
By John Lilleystone January 21, 2021
Remove whitespaces in Excel using the TRIM function.
excel iferror error alternate result
By john lilleystone April 11, 2020
Replace ugly Excel errors returned by a formula with something more appropriate and pleasing to the eye.
excel transpose
By john lilleystone March 14, 2020
Transpose and paste a vertical column of data horizontally into a row
edit hyperlink
By john lilleystone March 14, 2020
Edit a hyperlink in Outlook 2016
emoji symbol
By john lilleystone March 14, 2020
insert an emoji or symbol into your application
sparklines
By john lilleystone March 1, 2020
Add Sparklines to Excel tables to show trends in the data
random numbers randbetween
By john lilleystone March 1, 2020
Use the RANDBETWEEN function in Excel to randomly generate numbers between a specified upper and lower threshold.
By john lilleystone February 29, 2020
Import text files into Excel and use the Text to Columns wizard to separate the data into columns
By john lilleystone February 26, 2020
Return the last non-zero value in a row in Excel
By john lilleystone February 4, 2020
Extract values or strings from a cell from either the left, middle or right part of the cell
Show More