4 Replies Latest reply on Apr 17, 2015 3:34 PM by MartinBishop

    Date Countdown Loop

    MartinBishop

      Title

      Date Countdown Loop

      Post

      Hi,

      Need some help to output a countdown... 

      The date is the first Monday in August every year and once its hits the day, reset...

        • 1. Re: Date Countdown Loop
          raybaudi

          Try this  into an UNSTORED calculation field:

          Let([
          y = Year ( Get ( CurrentDate ) ) ;
          first august monday =  Date ( 8 ; Mod ( 2 - DayOfWeek ( Date ( 8 ; 1 ; y ) ) + 7 ; 7 ) + 1 ; y ) ;
          next august monday = Date ( 8 ; Mod ( 2 - DayOfWeek ( Date ( 8 ; 1 ; y + 1 ) ) + 7 ; 7 ) + 1 ; y + 1 ) ;
          first result = first august monday - Get ( CurrentDate ) ;
          next result = next august monday - Get ( CurrentDate )
          ];
          Case(
          first result ≥ 0 ; first result ; next result
          )
          )

          • 2. Re: Date Countdown Loop
            MartinBishop

            Thanks, that works perfectly...

            Would it also be possible to add "Tomorrow" if 1 day remaining and "Today" if 0 day? Thanks again!

            • 3. Re: Date Countdown Loop
              raybaudi

              Yes, change the result type to text and the Case ( ) statement to:

              Case(
              first result = 0 ; "Today" ;
              first result = 1 ; "Tomorrow" ;
              first result ≥ 2 ; first result ;
              next result
              )

              • 4. Re: Date Countdown Loop
                MartinBishop

                Oh yes, thanks a bunch working great. Mind helping on one more? Trying to show date countdown until Chinese New Year... The dates are all over the place, is there a way I can hard code in like 10 years worth of them? I would also like to output the same Today, Tomorrow, and additionally the duration of the holiday, each time its 15 days.

                For example:

                Feb. 16 - 3

                Feb. 17 - 2

                Feb. 18 - Tomorrow

                Feb. 19 - Today

                Feb 18 - 30 Days Remaining

                Feb 19 - 29 Days Remaining

                Feb 20 - 28 Days Remaining

                On day 0 should reset to the next year.

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   
                2014January 31Horse
                2015February 19Sheep
                2016February 8Monkey
                2017January 28Rooster
                2018February 16Dog
                2019February 5Pig
                2020January 25Rat
                2021February 12Ox
                2022February 1Tiger
                2023January 22Rabbit
                2024February 10Dragon
                2025January 29Snake

                <!--EndFragment-->