2 Replies Latest reply on May 13, 2012 6:51 AM by symbister

    Case Function query...

    symbister

      Title

      Case Function query...

      Post

      Hi

      Trying to set up a button to report on a previous week's attendances, so that no matter when it is run, it reports on Tuesday-Sunday. OK got the report running OK, with hard coded dates, but attempting a scripted step to set a variable to an 'offset', which will then be subtracted from today's DayOfYear, to give last Tuesday's DOY...

      but why doesn't this work? I've tried it in a set global variable script step, and tried it in a calculation field to set up a global value...

      Case (DayName ( Get ( CurrentDate ) = "Monday"); 6 ; DayName ( Get ( CurrentDate )  = "Tuesday") ; 7 ; DayName ( Get ( CurrentDate )  = "Wednesday") ; 8 ;  DayName ( Get ( CurrentDate )  = "Thursday") ; 9 ; DayName ( Get ( CurrentDate )  = "Friday") ; 10 ; DayName ( Get ( CurrentDate )  = "Saturday") ; 11 ; DayName ( Get ( CurrentDate )  = "Sunday") ; 12 ; 0 )

      Then the table has a calculation field to return DOY for the Creation Date, and this is used in the Find.

      all ideas welcome

       

        • 1. Re: Case Function query...
          raybaudi
          "but why doesn't this work?"

          Because DayName ( ) needs a date, not a boolean value always false.
          Try:

          Case(
          DayName ( Get ( CurrentDate ) ) = "Monday" ; 6 ;
          DayName ( Get ( CurrentDate ) ) = "Tuesday" ; 7 ;
          DayName ( Get ( CurrentDate ) ) = "Wednesday" ; 8 ; 
          DayName ( Get ( CurrentDate ) ) = "Thursday" ; 9 ;
          DayName ( Get ( CurrentDate ) ) = "Friday" ; 10 ;
          DayName ( Get ( CurrentDate ) ) = "Saturday" ; 11 ;
          DayName ( Get ( CurrentDate ) ) = "Sunday" ; 12 ;
          0
          )

          Of course there are better ways to obtain the same result like:

          Choose ( DayOfWeek ( Get ( CurrentDate ) ) ; "" ; 12 ; 6 ; 7 ; 8 ; 9 ; 10 ; 11 )
          • 2. Re: Case Function query...
            symbister

            tis a beautiful thing - a very elegant solution, thanks - haven't used Choose before.