Date Formula

Hello,

I am looking to write an formula that will work out how days are left until a certain date, 14 Sept 2023.

I have tried numerous times but can't quite get it to work.

past attempts:

DATE_DIFF(TODAY(), PARSE_DATE('2023-09-14'))

DATE_DIFF(DAY, CURRENT_DATE(), '2023-09-14', DAY)

 

The formula will be used to calculate the projected budget spend of a campaign, so I will using the average daily spend and multiplying by the number of days left of the campaign which ends on the 14 Sept 2023.

 

Any help would be greatly appreciated.

 

 

0 1 135
1 REPLY 1

Are you trying to do this in LookML/SQL or in an explore/Looker expression?

If you're trying to do it in LookML/SQL, the syntax will depend on your data warehouse. For example, in BigQuery: https://cloud.google.com/bigquery/docs/reference/standard-sql/date_functions#date_diff

If you're trying to do it in a Looker explore using a Looker expression, here are the relevant functions: https://cloud.google.com/looker/docs/functions-and-operators#date_functions

Based on your past attempts, I'm guessing probably SQL. Here's an example for BigQuery:

DATE_DIFF(DATE '2023-09-14', CURRENT_DATE(), DAY)

 

Top Labels in this Space