Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
3 years ago
Solved

M Query to pull only prior month data from HANA

Hi All, I’m trying to query a HANA view for only data from the month prior to the current month.  So if the current run date is 12/14/22, I’m looking for data with date values 11/01/22 thru 11/30/22...
  • Anonymous's avatar
    Anonymous
    3 years ago

    This is what worked for me:

    WHERE

                   (

                                  (

                                                 "PrimaryApproval" > Add_Months(Last_Day(current_date), -2)

                                                 AND "PrimaryApproval" <= Add_Months(Last_Day(current_date), -1)

                                  )

                                  OR (

                                                 (

                                                                "FinalApproval" > Add_Months(Last_Day(current_date), -2)

                                                                AND "FinalApproval" <= Add_Months(Last_Day(current_date), -1)

                                                 ) 

                                                 AND "PrimaryApproval" = '00000000'

                                      )

                   )