Forum Discussion

VivekKakkoth's avatar
VivekKakkoth
New Member
4 years ago
Solved

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.

5 Replies

  • ddpl's avatar
    ddpl
    Solution Sage

    try this

     

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

    • VivekKakkoth's avatar
      VivekKakkoth
      New Member

      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 ,

     

    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