4 Replies Latest reply on Dec 3, 2016 7:01 AM by David Moyer

    Get the date from the string

    aanshi

      I am generating report where I need to show search date. e.g. If I generate this report from 01/11/2016...30/11/2016 then report title should be Report from 01/11/2016 to 30/11/2016.

       

      For this I store search date into one variable now I want to differentiate this as From Date = 01/11/2016 &  To  Date = 30/11/2016 .\

       

      How to perform this?

       

      I cant to cut the string based on position. It should be cut the string by searching "..." . Because date format can be anything.

        • 1. Re: Get the date from the string
          keywords

          One option would be to create a pair of global fields: StartDate and EndDate. Instead of the user entering Find mode and posting the dates you could set up a script to complete the report. The script could look like this:

          1.     take the user to a layout on which these two field are placed, together with instructions to enter a start date and end date, then click a button to continue.

          2.     enter Find mode

          3.     use Set Field to insert the search criteria:  StartDate & "…" & EndDate

          4.     perform the Find

          5.     go to the Report layout

           

          The Start and End global fields will still have the values inserted by the user at this stage, and can be used in the report header:  "Report from " & StartDate & " to " & EndDate.

          • 2. Re: Get the date from the string
            erolst

            keywords wrote:

            [...]

            1. take the user to a layout on which these two field are placed, together with instructions to enter a start date and end date, then click a button to continue.

            2. enter Find mode

            [...].

            1. a, b, c ... Perform lots of error checking

             

            keywords wrote:

            [...] and can be used in the report header: "Report from " & StartDate & " to " & EndDate.

            Eg as a merge text, or a merge variable if it must be calculated (start = end? "Report for " & StartDate).

            • 3. Re: Get the date from the string
              David Moyer

              Hi,

              if you already have the string, you can use Substitute ...

              Substitute("1/2/2013...4/5/2016"; "..."; " to ")

              • 4. Re: Get the date from the string
                David Moyer

                also, you can use the word functions:

                LeftWords("1/1/2013...12/31/2013"; 1) = 1/1/2013

                RightWords("1/1/2013...12/31/2013"; 1) = 12/31/2013