Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

As per given document Odata filter on datetime not working with day, month, year etc function. #5481

Closed
anomepani opened this issue Mar 22, 2020 · 13 comments
Assignees
Labels
area:csom/rest/api Category: SharePoint Client Side Object Model SDK / REST API area:docs-comment Category: Comment left on bottom of a docs page here: https://docs.microsoft.com/sharepoint/dev listmaintenance-oldissues Marked for outdated issues as part of cleaning process status:to-be-reviewed Issue needs to be reviewed by Microsoft for additional follow up / review. type:bug-suspected Suspected bug (not working as designed/expected). See “type:bug-confirmed” for confirmed bugs. type:question Question... if answered, will be tagged as such.

Comments

@anomepani
Copy link

I am trying filter records based on datetime Odata filter on year function but not working. I have tested with below function

Date and time OData functions:

month()
year()
hour()
minute()
second()

does not seem to work with SharePoint Online REST Service

Error: The query is not valid

Document Details

Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

@msft-github-bot
Copy link
Collaborator

Thank you for reporting this issue. We will be triaging your incoming issue as soon as possible.

@msft-github-bot msft-github-bot added Needs: Triage 🔍 Awaiting categorization and initial review. area:docs-comment Category: Comment left on bottom of a docs page here: https://docs.microsoft.com/sharepoint/dev labels Mar 22, 2020
@andrewconnell
Copy link
Collaborator

Please provide some context... such as an example query. For example, have you verified the query is a valid OData query?

@andrewconnell andrewconnell added area:csom/rest/api Category: SharePoint Client Side Object Model SDK / REST API Needs: Author Feedback Awaiting response from the original poster of the issue. Marked as stale if no activity for 7 days. Needs: Context Detail ❓ Need more context detail around the issue. type:question Question... if answered, will be tagged as such. and removed Needs: Triage 🔍 Awaiting categorization and initial review. labels Mar 23, 2020
@msft-github-bot
Copy link
Collaborator

The more context details you can provide, the easier it is to help assist on issues. Any code you can provide and/or screenshots of the issue also help. The easier you can make it to reproduce the issue, the easier and quicker it is for someone to help you. Please refer to How to Create Good Issues, specifically How to Create Good Issues: Include context, in our wiki for more details.

@anomepani
Copy link
Author

I am using query like this, https://brsupport. Sharepoint.com/_api/Lists/GetByTitle('test')/items?$filter=year(salesdate) eq 2019
I am not sure where I am doing wrong, I am using below type filter.
$filter=year(salesdate) eq 2019
Tried with wrapping value in string as well
$filter=month(salesdate) eq '2019'

Hope this information will helpful

@msft-github-bot msft-github-bot added Needs: Attention 👋 Original poster responded to request for feedback, awaiting attention from Microsoft / community. and removed Needs: Author Feedback Awaiting response from the original poster of the issue. Marked as stale if no activity for 7 days. labels Mar 24, 2020
@Jerry0527
Copy link

Jerry0527 commented Mar 25, 2020

Please refer the same question in StackOverflow:
REST API filter by month

Use Listdata.svc:
/_vti_bin/listdata.svc/ListName?$filter=year(columnName) eq YearNumber

Example:
/_vti_bin/listdata.svc/test?$filter=year(salesdate) eq 2020

@anomepani
Copy link
Author

I have also tried same but for sharepoint online it's not working, I have Reffered this answer but as it's not working I have rised queries on github.

Thank for reply

@Jerry0527
Copy link

@anomepani, Listdata.svc is still available in SharePoint Online.
What's the response in your side ? Is there any error status.
You can also do a Post Request with CAML same as the Option 2 in the similar thread above.

@andrewconnell
Copy link
Collaborator

andrewconnell commented Mar 25, 2020

The primary OData endpoint, _api, should respect these functions per the docs. You should not be reverting back to the legacy listdata.svc endpoint or having to revert to CAML.

I can repro your error.

Investigating & will follow up...

@andrewconnell andrewconnell added status:to-be-reviewed Issue needs to be reviewed by Microsoft for additional follow up / review. type:bug-suspected Suspected bug (not working as designed/expected). See “type:bug-confirmed” for confirmed bugs. and removed Needs: Attention 👋 Original poster responded to request for feedback, awaiting attention from Microsoft / community. Needs: Context Detail ❓ Need more context detail around the issue. labels Mar 25, 2020
@andrewconnell andrewconnell self-assigned this Mar 25, 2020
@bcameron1231
Copy link
Contributor

fwiw, I've never seen date functions work in the REST API, only in the SOAP APIs.

@diveshgup
Copy link

Hello,

I am trying to filter on a datetime field and i am getting issues.

When i use rest api and filter on Created, it works. however when i use EventDate, it does not.
When i use listdata.svc, same issue occurs.

Thanks.
Divesh

@thailakadre
Copy link

Hi, I am trying to use the OData function too in power automation(Flow). And I am receiving the same error.

Error:
body":{"status":400,"message":"The query is not valid.\r\nclientRequestId: xxxxxxxxxxxxxb\r\nserviceRequestId: xxxxxx"}}

Filter query.
day(Birthday) eq 28 and month(Birthday) eq 10

Please, someone knows if I am doing something wrong or if this error still happens?

@VesaJuvonen VesaJuvonen added the listmaintenance-oldissues Marked for outdated issues as part of cleaning process label Dec 29, 2021
@ghost
Copy link

ghost commented Dec 29, 2021

This issue is being closed as part of an issue list cleanup project. Issues with no activity in the past 6 months that aren't tracked by engineering as bugs were closed as part of this inititive. If this is still an issue, please follow the steps outlined to re-open or submit a new issue.

@ghost ghost closed this as completed Dec 29, 2021
@ghost
Copy link

ghost commented Jan 5, 2022

Issues that have been closed & had no follow-up activity for at least 7 days are automatically locked. Please refer to our wiki for more details, including how to remediate this action if you feel this was done prematurely or in error: Issue List: Our approach to locked issues

@SharePoint SharePoint locked as resolved and limited conversation to collaborators Jan 5, 2022
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area:csom/rest/api Category: SharePoint Client Side Object Model SDK / REST API area:docs-comment Category: Comment left on bottom of a docs page here: https://docs.microsoft.com/sharepoint/dev listmaintenance-oldissues Marked for outdated issues as part of cleaning process status:to-be-reviewed Issue needs to be reviewed by Microsoft for additional follow up / review. type:bug-suspected Suspected bug (not working as designed/expected). See “type:bug-confirmed” for confirmed bugs. type:question Question... if answered, will be tagged as such.
Projects
None yet
Development

No branches or pull requests

8 participants