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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
VivekKakkoth
New Member

Query Data for a Specific Date

Hi ,

 

I am new to Power Bi and I am trying some reporting stuffs with Power BI.

 

I am trying to query some data from a DB2 database which I have connected via the ODBC connections. My requirement here is to fetch data for the current date.

Take a look at a simple SQL query : 

select * from tablename where date = dt.

here date is the variable from my table and dt should be the current date that I want.

 

Any guidance.

1 ACCEPTED SOLUTION

Hi @VivekKakkoth 

 

Try using CURRENT DATE instead. Specifying CURRENT_DATE is equivalent to specifying CURRENT DATE.

SELECT * FROM tablename WHERE date = CURRENT DATE

Reference: https://stackoverflow.com/questions/32478642/how-to-select-data-from-db2-for-current-date 

 

In addition, Current date is in yyyy-mm-dd format. If your date column is in other format, you may need to convert its format. Please refer to https://stackoverflow.com/questions/10320918/db2-date-format 

 

Best Regards,
Community Support Team _ Jing
If this post helps, please Accept it as Solution to help other members find it.

View solution in original post

5 REPLIES 5
BA_Pete
Super User
Super User

Hi @VivekKakkoth ,

 

In Power Query M, you would bring in all the data, then filter as follows:

 

Table.SelectRows(
    previousStepName,
    each [date] = #date(2022, 05, 01)
    // OR: each [date] = variableName to use a defined variable
    // OR: each [date] = Date.From(DateTime.LocalNow()) to use today's/current date
)

 

 

Pete



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

Proud to be a Datanaut!




ddpl
Solution Sage
Solution Sage

try this

 

SELECT * FROM table where DATE(date)=CURDATE()

DATE(date)=CURDATE()

 

These formats are not working.. I had tried this option before I posted this requirement. It is throwing an SQL error as : 

 

Query1
ODBC: ERROR [42884] [IBM][CLI Driver][DB2] SQL0440N No authorized routine named "CURDATE" of type "" having compatible arguments was found. SQLSTATE=42884

Hi @VivekKakkoth 

 

Try using CURRENT DATE instead. Specifying CURRENT_DATE is equivalent to specifying CURRENT DATE.

SELECT * FROM tablename WHERE date = CURRENT DATE

Reference: https://stackoverflow.com/questions/32478642/how-to-select-data-from-db2-for-current-date 

 

In addition, Current date is in yyyy-mm-dd format. If your date column is in other format, you may need to convert its format. Please refer to https://stackoverflow.com/questions/10320918/db2-date-format 

 

Best Regards,
Community Support Team _ Jing
If this post helps, please Accept it as Solution to help other members find it.

This Worked !!! 😃

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.