cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

SQL Get Rows - Date Filter Between Two Dates

Hi All,

 

Read a few posts regarding this issue and havin the same problem.

 

My data looks like this:

1.PNG

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

 

2.PNG

 

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: 

 

3.PNG

 

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! Smiley Very Happy

 

1 ACCEPTED SOLUTION

Accepted Solutions
Anonymous
Not applicable

Re: SQL Get Rows - Date Filter Between Two Dates

@v-xida-msft

 

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.

2 REPLIES 2
Community Support Team
Community Support Team

Re: SQL Get Rows - Date Filter Between Two Dates

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:6.JPG

The datatime column that Microsoft Flow get as below:7.JPG

 

I have made a test on my side and please take a try with the following workaround:

  • Add a proper trigger, here I use Flow Button trigger.
  • Add “Get rows” action, Filter Query field set to following formula:
Year(DueTime) ge 2018 and month(DueTime) ge 1 and day(DueTime) ge 27
  • Add “Get rows 2” action, specify same Table name with “Get rows” action, Filter Query set to following formula:
Year(DueTime) ge 2018 and month(DueTime) le 2 and day(DueTime) le 2
  • Add a “Compose” action, Inputs set to following formula:
union(body('Get_rows')?['value'],body('Get_rows_2')?['value'])

Image reference:8.JPG

 

9.JPG

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:10.JPG

 

Best regards,

Kris

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

Re: SQL Get Rows - Date Filter Between Two Dates

@v-xida-msft

 

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.

Helpful resources

Announcements
firstImage

Microsoft Business Applications Virtual Launch Event

Join us for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

Power Platform 2019 Release Wave 2 Plan

Power Platform 2019 Release Wave 2 Plan

Features releasing from October 2019 through March 2020

thirdimage

Flow Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

fifthimage

Microsoft Learn

Learn how to build the business apps that you need

sixthImage

Power Platform World Tour

Find out where you can attend!

seventhimage

Webinars & Video Gallery

Watch & learn from the Flow Community Video Gallery!

Users Online
Currently online: 193 members 4,340 guests
Please welcome our newest community members: