How to get a dynamic CosmosDB query of last 30 days documents in Logic App environment?

Lee Yong Sheng 41 Reputation points
2022-07-11T13:50:55.35+00:00

Hi Microsoft community

I am trying to query CosmosDB documents of the last 30 days in Azure Logic Apps environment which will give a monthly report summary of something.
Below is the snapshot of trying in CosmosDB environment using the SQL query.
219565-cosmos-1.jpg
It gives an empty result with no error.

Appreciate if someone has experience could help to have look.
Thank you and regards
Yong Sheng

Azure Logic Apps
Azure Logic Apps
An Azure service that automates the access and use of data across clouds without writing code.
3,336 questions
Azure Cosmos DB
Azure Cosmos DB
An Azure NoSQL database service for app development.
1,749 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Kamlesh Kumar 3,866 Reputation points
    2022-07-11T18:25:05.487+00:00

    Hi @Lee Yong Sheng ,

    Welcome to Microsoft Q&A Platform. Thank you for the question.

    Please run the query without where clause and see if you are able to get the result,

    Because query that you are using seems correct,

    DateTimeDiff (<DateTimePart> , <StartDate> , <EndDate>)  
    

    Example:

    SELECT DateTimeDiff("day", "2020-01-01T01:02:03.1234527Z", "2020-01-03T01:02:03.1234567Z") AS DifferenceInDays  
    

    Refer the MS documentation

    Regards,
    Kamlesh Kumar
    BizTalk Techie

    Please don't forget to click on 205836-130616-image.png or upvote 205759-130671-image.png button whenever the information provided helps you. Original posters help the community find answers faster by identifying the correct answer. Here is How

    Want a reminder to come back and check responses? Here is how to subscribe to a Notification

    If you are interested in joining the VM program and help shape the future of Q&A: Here is how you can be part of Q&A Volunteer Moderators

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.