intacct / intacct-sdk-net

Official repository of the Sage Intacct SDK for .NET
https://developer.intacct.com/tools/sdk-net/
Apache License 2.0
31 stars 45 forks source link

Query Using Date Range #25

Closed jmawebtech closed 6 years ago

jmawebtech commented 6 years ago

Hi,

I would like to query payments created from 2/1/2018 to 2/28/2018. Can I query using a date range?

    public List<ARPAYMENT> SearchPaymentsByDate(DateTime beginDate, DateTime endDate)
    {
        GreaterThanOrEqualToDateTime query = new GreaterThanOrEqualToDateTime()
        {
            Field = "WHENCREATED",
            Value = beginDate
        };

        LessThanOrEqualToDateTime query = new LessThanOrEqualToDateTime ()
        {
            Field = "WHENCREATED",
            Value = endDate
        };

        ReadByQuery readByQuery = new ReadByQuery()
        {
            ObjectName = "ARPayment",
            Fields = { "*" },
            Query = query
        };

        Task<OnlineResponse> task = Client().Execute(readByQuery);
        task.Wait();
        OnlineResponse response = task.Result;
    }
jimmymcpeter commented 6 years ago

Yeah, you can use the AndCondition class with your two queries as conditions in it. Check out the test for it here - https://github.com/Intacct/intacct-sdk-net/blob/master/Intacct.SDK.Tests/Functions/Common/Query/Logical/AndConditionTest.cs#L40