5 Replies Latest reply on Jun 30, 2014 3:28 PM by philmodjunk

    Date and time calculation if available

    ChrisJohnston

      Title

      Date and time calculation if available

      Post

           Trying to find a way to get a date and time that is calculated by subtracting 3 or 5 days when available. I will have another field that will hold the date to be subtracted from. When the information of 3 or 5 days is not available, I want to be able to manually enter it via a dropdown calendar. Would a good idea to begin, be to make a field that is a timestamp that has auto enter IF the is a value in the field that holds 3 or 5 days? Or is there a better way to do this? Thanks

        • 1. Re: Date and time calculation if available
          philmodjunk

               To subtract 3 days from a date in a date field to get a date 3 days earlier:

               DateField - 3

               Just select date as your result type.

               To do this for a timestamp field you have to subtract the equivalent number of seconds: TimestampField - 3 * 24 * 3600

               But I'm not sure I understand what you mean by your description of selecting a date manually and how that enters in here. DateField can certainly be formatted with a drop down calendar. Is that what you want?

          • 2. Re: Date and time calculation if available
            ChrisJohnston

                 I don't always have the information of 3 days, when that is the case I will need to enter a date manually. I want to use the subtraction when it is available information, when not I want to pick the date from a drop down. Thanks

            • 3. Re: Date and time calculation if available
              philmodjunk

                   Please explain what you mean by "the information of 3 days". How is that specified in your database?

              • 4. Re: Date and time calculation if available
                ChrisJohnston

                     When I know the end time it is specified by me using a date picker to choose the end time. I will sometimes know that if our end time is Thursday July 3rd 2014 9:00 PM that our time spanned of this transaction was 3 days. So subtracting 3 days from that would make it Monday June 30th 2014 9:00 PM. Other times I will not know the end time or how many days it spanned so I need to enter it manually later. I want a way to possibly use a drop down that picks the duration of days (in another field) when applicable to insert the date minus 3 or 5 days (drop down) or just use a date picker to enter it manually. I want the "either or" option of entering the date. Thanks

                • 5. Re: Date and time calculation if available
                  philmodjunk

                       Your thread topic mentions "date and time" but all of your posts only describes this in terms of a date. So I will keep things simpler by assuming that you only need to calculate or enter a date and show it in a date field.

                       You can set up this auto-enter calculation on a date field:

                       If ( IsEmpty ( Duration ) ; self ; self - Duration )

                       Where Duration is the field where you "use a drop down that picks the duration of days"

                       I think you'll also need to clear the "do not replace existing value" check box but test and see. (Clear the duration field first if you select a duration and then later choose to enter the exact date.)