Error with now()

done
low_priority
reply

(Ajinkya Potdar) #1

Hi all,

I am getting “SQL compilation error: Invalid identifier NOW” error when trying to create below Dimension. Can you anyone advise how to get current date ?
I am using Looker 6.6. Any help would be appreciated.

dimension: test_case  {
  	type: number
  	sql: CASE
       
		WHEN ${shipped_date} IS NULL THEN DATEDIFF(${created_date} - now())
          
		ELSE DATEDIFF(${created_date} - ${shipped_date})

        END
;;
}

Thanks


(Andrew Powell) #2

Hey,

The function to get the current date depends on the dialect of SQL you are using. The date diff function usually has a different format than that too.

What database are you using?

Andy


(Ajinkya Potdar) #3

Hey Andy,

Thanks for the lead. CURRENT_DATE() worked.