Method Community

 

how to fetch the data based on my current Date

Last post 05-13-2024 10:15 AM by Method_Paul. 3 replies.
Page 1 of 1 (4 items)
Sort Posts: Previous Next
  • 05-10-2024 5:03 PM

    how to fetch the data based on my current Date

    Hi all, 

    I would like to filter and fetch the record based on my current day ,  for example : https://rest.method.me/api/v1/tables/SalesOrder/?filter=TxnDate eq '2024-05-09 13:00:00 -05:00'   here instead of static date  

    I want to dynamically filter and retrieve records based on the current day. For instance, using this API endpoint: https://rest.method.me/api/v1/tables/SalesOrder/?filter=TxnDate eq 'CURRENT_DATE'. This way, the system will automatically extract data for the present date each time."


    Any assistance would be greatly appreciated

    Thanks,

  • 05-10-2024 5:17 PM In reply to

    Re: how to fetch the data based on my current Date

    Hi there. I think you are better off doing "between" rather than equal, when it comes to dates.

    We have some documentation on this here:
    https://developer.method.me/#section/Filter-Reference

    "To get all Invoices created on April 17, 2020, EDT (Eastern Daylight Time)"

    GET /api/v1/tables/Invoice?filter=TimeCreated ge '2020-04-17T00:00-04:00' and TimeCreated lt '2020-04-18T00:00-04:00' HTTP/1.1 
    Host: https://rest.method.me
    Authorization: Bearer eyJhbGciOiJSU

    Hopefully that helps put you in the right direction,

    Paul

    
    
    
    										    
    									    
  • 05-13-2024 9:31 AM In reply to

    Re: how to fetch the data based on my current Date dynamically

    I already know that  i can do this

    GET /api/v1/tables/Invoice?filter=TimeCreated ge '2020-04-17T00:00-04:00' and TimeCreated lt '2020-04-18T00:00-04:0

    But My quesition is it should be dynamic for eachday , i don't want to put  static Date everyday, I want automation so that i don't have put current date on filter section.  I want to fetch each day data autometically from the SalesOrder

    I don't want to  put  '2020-04-17T00:00-04:00' like this date Manually each day  , there must be some functions which autometically catch current date.
  • 05-13-2024 10:15 AM In reply to

    Re: how to fetch the data based on my current Date dynamically

    The expectation is that your code that is using the API is responsible for business logic.  So in your code, you would create and manage dynamic variables to reflect your desired business logic, and that you'd then call the API to get the data you need.

    Paul

Page 1 of 1 (4 items)