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

Handle datetime fields in OData queries #1173

Closed
1 task done
NicolaiLassesen opened this issue May 9, 2023 · 2 comments
Closed
1 task done

Handle datetime fields in OData queries #1173

NicolaiLassesen opened this issue May 9, 2023 · 2 comments
Assignees
Labels
area: framework ⚙ Changes in the SDK core framework code

Comments

@NicolaiLassesen
Copy link

NicolaiLassesen commented May 9, 2023

Category

  • Feature request

Describe the feature

Currently ODataUtilities (PnP.Core\QueryModel\OData\ODataUtilities.cs) is not able to correctly format DateTime values when filtering on such.

Describe the solution you'd like

DateTime values (and DateTimeOffset values) should be converted to UTC and correctly formatted in ISO format. Adding these cases to the switch in the ConvertToString method would solve this problem:

                case DateTime dt:
                    return $"datetime'{dt.ToUniversalTime():yyyy-MM-ddThh:mm:ssZ}'";
                case DateTimeOffset dto:
                    return $"datetime'{dto.UtcDateTime:yyyy-MM-ddThh:mm:ssZ}'";
@jansenbe
Copy link
Contributor

jansenbe commented May 9, 2023

Thanks for using PnP Core SDK and providing feedback @NicolaiLassesen. I'll make the necessary changes for this.

@jansenbe jansenbe self-assigned this May 9, 2023
@jansenbe jansenbe added the area: framework ⚙ Changes in the SDK core framework code label May 9, 2023
jansenbe added a commit that referenced this issue May 9, 2023
…e` and `DateTimeOffset` types in OData filters #1173
@jansenbe
Copy link
Contributor

jansenbe commented May 9, 2023

@NicolaiLassesen : I've implemented this change, will be part of the next nightly build (version 1.9.42 or higher). I'm closing this issue now, but feel free to re-open or create a new one in case the created fix is not working for you.

@jansenbe jansenbe closed this as completed May 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: framework ⚙ Changes in the SDK core framework code
Projects
None yet
Development

No branches or pull requests

2 participants