Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
Anonymous
Not applicable

Last 7 days query, error near '<'

 I have a query I am running it selects data from 2 tables. I am trying to get get both tables to uese the same date range. The query below was modified to try to get both tables to return the last 7 days worth of data. The blue text is what I added.

WHERE (d.TimeDown >= DATEADD(day, - 7, GETDATE(), (Date >= DATEADD(day, -7, GETDATE()))"]),  I get a syntax error near ">" which started when I added the second date statement. Can this be resolved, or am I writing this incorrectly? So far, my original table will pull the last 7 days as requested, but the second table delivers everything since 2005.

2 REPLIES 2
Anonymous
Not applicable

No, I am looking for the past 7 days. Today, I would be looking for June 7th thru June13th from both tables One uses the the 'TimeDown' field as the date, the other currently uses 'Date' Note: I could use TimeOpen in table 2, which would give me two date/time fields (if that is easier).

amitchandak
Super User
Super User

@Anonymous , are you writing a SQL in advance option

 

try like

WHERE (d.TimeDown >= DATEADD(day, - 7, GETDATE()) and (d.TimeDown <= DATEADD(day, 0, GETDATE())))

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

Find out what's new and trending in the Fabric community.