SQL tanslations for datediff in dbplyr?

Found a better way!

Previous solution:

mutate(day = "DAY", invoice_age_days = DATEDIFF(DAY, `INVOICE DATE`, GETDATE())) %>%
      select(-day) %>%

Better solution

mutate(invoice_age_days = DATEDIFF(sql("DAY"), `INVOICE DATE`, GETDATE()))

ref:

New solution does not require a dummy value.

1 Like