6 Replies Latest reply on Mar 22, 2018 9:31 AM by Jim Dehner

    Datetrunc error when combine with datename

    betsy curbelo

      Hi I need to create a  calculated field that returns the weekday for every jan1 and then use it with datetrunc to divide the year in weeks starting always on jan1

       

      1- I create a parameter (year) with a last of year 2005-till now so the user can select any year in the database

      2-create a a field (date) with the parameter (

      IF Year([Calendar Date])= [Year]
      THEN
      [Calendar Date]
      END
      )

      then use this formula

      DATETRUNC('week', [Date] ,DATENAME('weekday',DATE('01/01/'+ STR([Year]))))

      but I having this error

       

      'Argument 3 to DATETRUNC must be a(n) string'

      so I change the formula

      DATETRUNC('week', [Date] , str(DATENAME('weekday',DATE('01/01/'+ STR([Year])))))

      and again same error

      PLS HELP