Hi All,
Read a few posts regarding this issue and havin the same problem.
My data looks like this:
Where MetricDate = datetime data type in SQL Server.
I want to return 7 records between 2018-01-27 and 2018-02-02 so my SQL statement would be:
MetricDate >= '2018-01-27' and MetricDate <= '2018-02-02'
However I cant get the ODATA filter query to work correctly and I have tried pulling out Year,Month and Day seperately as per other post.
I can get all of January and Feburary to return using:
Year(MetricDate) ge 2018 and Month(MetricDate) ge 1 and Month(MetricDate) le 2
Adding the days in the following doesnt return any retuls:
Year(MetricDate) ge 2018 and Month(MetricDate) ge 1 and Month(MetricDate) le 2 and Day(MetricDate) ge 27 and Day(MetricDate) le 2
Ive also tried MetricDate ge datetime'2018-01-27' and MetricDate le datetime'2018-02-02' which would be so much easier but get the following error:
and i'm not sure why, what version of ODATA does FLOW use?
Any help on how to search between two dates using an ODATA filter would be massive help, the point of this is to limit the records used as a data source (depending upon user date selections in the app) to pull into PowerApps (due to the 500 record limitation), so i really need this to work.
I'm also using an On-Premises Gateway if info required.
Help please! 😄
Solved! Go to Solution.
Many thanks for that detailed response.
It was very useful.
However as my date range is variable upon user select it could be for days,weeks,months even years. The solution would require to pull more records than needed.
I have implemented my own workaround and created an int column within my date where by my MetricDate is converted to int here, that way i can query between two int ranges in the ODATA filter and this is working as expected now.
Thanks again for your help.
Hi @jmc17,
The date time in SQL table would be converted into UTC format automatically in Microsoft Flow. The datatime column in my SQL table as below:
The datatime column that Microsoft Flow get as below:
I have made a test on my side and please take a try with the following workaround:
Year(DueTime) ge 2018 and month(DueTime) ge 1 and day(DueTime) ge 27
Year(DueTime) ge 2018 and month(DueTime) le 2 and day(DueTime) le 2
union(body('Get_rows')?['value'],body('Get_rows_2')?['value'])
Image reference:
Note: There is no OData query to filter records between two dates in one “Get rows” action of Microsoft Flow currently.
The flow works successfully as below:
Best regards,
Kris
Many thanks for that detailed response.
It was very useful.
However as my date range is variable upon user select it could be for days,weeks,months even years. The solution would require to pull more records than needed.
I have implemented my own workaround and created an int column within my date where by my MetricDate is converted to int here, that way i can query between two int ranges in the ODATA filter and this is working as expected now.
Thanks again for your help.
Hi Why don't you share your solution to others. i have the similar issue. when i use day(date) function in my filter query, which is not returning proper value all the time.
in my filter query i am using the following
Month(MODIFIED_DATE) ge 2
day(MODIFIED_DATE) ge 27
Thanks Kris
I got this working ...
year(TargetDate) le @{formatDateTime(addHours(utcNow(),1),'yyyy')} and
month(TargetDate) le @{formatDateTime(addHours(utcNow(),1),'MM')} and
day(TargetDate) le @{formatDateTime(addHours(utcNow(),1),'dd')} and
hour(TargetDate) le @{formatDateTime(addHours(utcNow(),1),'HH')}
Copy and past the above into the 'Filter Query' section as is. I had to add an extra hour to get the current time (UK GMT Summer time, clock madness), so change that as you see fit. Change 'le' to 'gt' or 'eq' depending on what you want to do.
This checks DB field date (datetime field) against the current time.
Change 'TargetDate' for whatever datetime field you are using.
by the way, don't try and check for minutes as that ws turning into a hit and miss ..... uumm .. unless i bracket it .. if you getting minutes working consistently, please update my code and let me know.
Hi All,
This seems to be case sensitive and does not work with time (not sure why). A Date field in SQL works, and DateTime/Datetime2 field does not.
Lots of testing to get to this point, but if you can split your date and time, you may be able to use this.
Tested with SQL16 on prem.
The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.
Learn to digitize and optimize business processes and connect all your applications to share data in real time.
User | Count |
---|---|
12 | |
11 | |
9 | |
9 | |
6 |
User | Count |
---|---|
25 | |
21 | |
17 | |
8 | |
8 |