Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
Hello,
Sorry if this isnt the best forum to ask this, but Im digging into a SQL data warehouse, which uses a date field. The data is populated from 2004 onwards, but I only want to pull the event data for date rows equal or later than TODAY, and less than or equal to 3 months from now. I can hard code the dates (showm below), but I want this to be automatic and ongoing.
Any ideas?
Here's the hard coded exmaple... Whats the SQL code needed to replace the hard dates with Today until 3 months from now?
select *
from TABLE_DETAILS
where EVENT_CODE = 'XS'
and EVENT_DATE between '01-SEP-16' and '01-DEC-16'
Solved! Go to Solution.
From a purely SQL perspective, you want to use
getdate()
to get the current date/time (convert with a mask to eliminate time if necessary)
and
dateadd(month, 3, getdate())
to get the date 3 months from now (use same convert mask if needed).
From a purely SQL perspective, you want to use
getdate()
to get the current date/time (convert with a mask to eliminate time if necessary)
and
dateadd(month, 3, getdate())
to get the date 3 months from now (use same convert mask if needed).
The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!
| User | Count |
|---|---|
| 37 | |
| 37 | |
| 33 | |
| 32 | |
| 29 |
| User | Count |
|---|---|
| 130 | |
| 88 | |
| 82 | |
| 68 | |
| 64 |