3 Replies Latest reply on Jun 13, 2017 8:39 AM by kht

    Date Calc


      IO am just trying to figure out a simple date calculation. I have a admin preference called XeroStartDate. When I upload records, I want the upload script to first check the Invoice date does not predate the XeroStartDate field. Any ideas?

        • 1. Re: Date Calc

          kht wrote:

          the Invoice date does not predate the XeroStartDate field.

          The expression


          Invoice::theDate >= Preferences::XeroStartDate


          would have to be true.


          (Or, if you prefer, Preferences::XeroStartDate < Invoice::theDate)

          • 2. Re: Date Calc

            It kind of depends on where you're uploading from. To my knowledge, there's no way to validate data on an import, however you could validate it afterwards.

            Set a created_at field with the option to auto populate with a timestamp on creation. Before the import step, set a variable $time = Get(CurrentTimeStamp). Then after the import step do a find for created_at > $time and Invoice::Date < AdminPreference::XeroStartDate then Delete Found Set.

            What that will do is search through all the records you just uploaded and find ones that have a Date before XeroStartDate, and delete them.


            Alternatively, you could look into how field validations work with Imports. I'm not sure if the import will stop when an entry fails validation, though. For instance, you may be able to set a validation by calculation on the Date field, where Invoice::Date >= AdminPreference::XeroStartDate

            • 3. Re: Date Calc

              Thanks. I was clearly not thinking straight. I was thinking about using a Get(current date) but this is not relevant. All working.