Calculating future date

Viewing 11 reply threads
  • Author
    Posts
  • June 5, 2023 at 10:42 AM #49542

    Mike Guilbault
    Participant

    I’m sure it’s simple, but I can’t seem to get it right. How do you calculate a field to add “x” days from another date field? In other words, new date = date + 14 days (for example).

     

    Thanks!

    June 5, 2023 at 2:51 PM #49547

    Daniel Leu
    Participant

    Have a look at following response to a similar question: https://www.tapforms.com/forums/topic/how-to-increase-a-date-in-a-script/#post-49372

    June 6, 2023 at 6:08 AM #49558

    Mike Guilbault
    Participant

    Awesome… didn’t know about DATEADD. Now, how do I format it into YY-MM-DD. It’s returning the long date including time (May 25, 2023 at 12:00:00 AM).

    I tried DATE(DATEADD([COMPLETED];0;0;0;14;0;0;0);”YY-MM-DD” but that didn’t work. Returned “December 31, 1969 at 12:00:00 AM”.

    June 6, 2023 at 7:16 AM #49559

    Daniel Leu
    Participant

    DATE() is the correct function to use with a text return type. Or it might be that you are missing a closing bracket in your formula DATE(DATEADD([COMPLETED];0;0;0;14;0;0;0);”YY-MM-DD”).

    June 6, 2023 at 7:23 AM #49560

    Mike Guilbault
    Participant

    Tried it again (checked my brackets). Unfortunately, that returns: Dec 31, 1969 at 7:00:23 PM

    Back to square one.

     

    June 6, 2023 at 10:22 AM #49562

    Daniel Leu
    Participant

    Did you set the the return type to text?

     

    • This reply was modified 1 year, 6 months ago by Daniel Leu.
    • This reply was modified 1 year, 6 months ago by Daniel Leu.
    Attachments:
    You must be logged in to view attached files.
    June 6, 2023 at 10:23 AM #49563

    Mike Guilbault
    Participant

    I tried it both ways. no go.

    June 6, 2023 at 10:45 AM #49567

    Daniel Leu
    Participant

    Strange…. Let’s see if @brendan has an idea. BTW, it should be lower case “dd”, upper case “DD” is day of year. And lower case “yy” as well. Here is the link to the explanation of the format http://www.unicode.org/reports/tr35/tr35-31/tr35-dates.html#Date_Format_Patterns

    June 6, 2023 at 10:49 AM #49568

    Daniel Leu
    Participant

    Maybe go back to your original implementation and set the date format in the field options.

     

    • This reply was modified 1 year, 6 months ago by Daniel Leu.
    Attachments:
    You must be logged in to view attached files.
    June 7, 2023 at 9:59 AM #49571

    Mike Guilbault
    Participant

    Thanks for the info on date formats… I was wondering how that worked.

    June 7, 2023 at 10:05 AM #49572

    Mike Guilbault
    Participant

    THAT DID IT!  I knew it would be something simple.  Thanks Daniel. Much appreciated!

    June 7, 2023 at 11:03 AM #49573

    Daniel Leu
    Participant

    Great that this did the trick. It sill puzzles me why DATE() didn’t work for you.

    June 8, 2023 at 11:27 AM #49574

    Brendan
    Keymaster

    My thoughts are if the Date Format setting worked, then the code was returning a Date value and not Text.

Viewing 11 reply threads

You must be logged in to reply to this topic.