5 Replies Latest reply on Aug 7, 2009 9:32 AM by ABC_Mac

    Get tomorrow's date, the next day, etc

    ABC_Mac

      Title

      Get tomorrow's date, the next day, etc

      Post

      I'm trying to get a field to return a date in the future.  Bear with me while I try to explain.  Each record has a "date created" filled which auto-populates with the day it was created.  There is another "priority level" field that is then defined by the user.  Based on this information, I want to create a field that is the "date due", so that the due date will auto-populate with a date 2, 3, 4, etc days in the future, depending on the contents of the priority level and the date created.  I know about Get (CurrentDate) but is there a way to essentially do Get (CurrentDate) + 2?  Thanks for your help!

        • 1. Re: Get tomorrow's date, the next day, etc
          hiatts
            

          from my knowledge, you need to use the month day year function to break current date into its main components.

          then, you reassemble it withe date(month(currentdate), day(currentdate) + x, year(currentdate)) 

          • 2. Re: Get tomorrow's date, the next day, etc
            philmodjunk
              

            Not essentially but exactly!

             

            Get ( currentdate ) + 2 in a calculation that returns date will give you a date that is two days in the future.

             

            In your case, I'd use datefield + 2 where "datefield" is the field where you are auto-entering the creation date.

             

            This works because date fields are simply integer number fields that count the number of days since an early arbitrary date with special format options to display as dates. Thus, you can simply use them as number fields in calculation expressions.

            • 3. Re: Get tomorrow's date, the next day, etc
              ABC_Mac
                 Thanks Phil that worked perfectly!  One last caveat, and this may be asking too much, but is there a way to get it to only evaluate weekdays?  I can get the due date to be 3 days later, but if the date created is a Friday, for example, is it possible to get the due date to be Wednesday instead of Monday?
              • 4. Re: Get tomorrow's date, the next day, etc
                philmodjunk
                  

                Yes, there's a dayofweek function that returns a number:1 = Sunday, 2 = Monday, .... 7 = Saturday.

                 

                There are a number of ways to do this and another forum member may have a better way, but the following works for me:

                 

                datefield + 2 + Case (dayofweek(datefield) = 5, 2, dayofweek(datefield) = 6, 2, 0 )

                 

                This assumes that no one enters data on a weekend date. If you need to allow for that possibility, you'll need to add more parameters to the case function.

                • 5. Re: Get tomorrow's date, the next day, etc
                  ABC_Mac
                     Perfect!  Thanks so much!