BVS
BVS

Reputation: 421

Azure Logic App: Filter Query Difference between dates should not exceed 10 months

Like in SQL Server, we find the difference between dates using DATEDIFF as below, I'm try with OData filter Query in SQL Server - Get Rows Connector but I don't see a DateDiff function available.

SELECT DATEDIFF(month, DateOfBirth, GETDATE()) AS DateDiffInMonths from employees where DateDiffInMonths > 10;

I've tried below ODATA query by referring few links of Power Automate but it doesn't work as DateDiff doesn't exist in Expressions looks like

DateDiff(utcNow(), DateOfBirth, Months ) ge 10

Could you please share suggestions on how we can achieve this using OData Filter query or any other way to filter out table records straight away during Get Rows itself?

Thanks in Advance

Upvotes: 0

Views: 1671

Answers (1)

SwethaKandikonda
SwethaKandikonda

Reputation: 8244

To query for 10 months you can use filter query to be

month(hire_date) lt month(@{subtractFromTime(utcNow(),10,'Month')})

For example:- Consider I have these records

enter image description here

enter image description here

Here is the output

enter image description here


In General you can use

year(hire_date) gt year(<Timestamp>) and 
month(hire_date) gt month(<Timestamp>) and 
day(hire_date) gt day(<Timestamp>) and so on

You can even change the datetime format and have the comparison for the same.

To query in general

enter image description here

Here is the output I received

enter image description here

REFERENCES: Azure Logic App SQL ODATA Filter on Date

Upvotes: 1

Related Questions