Reputation: 421
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
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
Here is the output
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
Here is the output I received
REFERENCES: Azure Logic App SQL ODATA Filter on Date
Upvotes: 1