Advent of Code is back! Unwrap daily challenges to sharpen your Alteryx skills and earn badges along the way! Learn more now.

Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.

In Database Calculation for Average Difference between two dates

HowRy002
6 - Meteoroid

Team - 

 

I'm trying to use the in database formula tool to calculate the Average difference between two dates. I would think it would be a DateDiff formula but that constantly errors. 

 

Example: DateDiff(days, "Latest_Date", "Early_Date",) 

 

Everything I try error's.....

 

Suggestions?

 

Ryan

 

3 REPLIES 3
LindonB
11 - Bolide

Hi there,

First, each database system has its own set of functions and syntax rules. While the core concept of calculating date differences remains the same, the implementation (how to write the SQL) vary. 

Your syntax seems to match SQL server.
DATEDIFF(day, [Early_Date], [Latest_Date])

For Snowflake though, you'd need:
DateDiff('days', [Latest_Date], [Early_Date])

...and for MySQL, you'd use....
DATEDIFF([Latest_Date], [Early_Date])


HowRy002
6 - Meteoroid

Thanks Lindon - appreciate the response. We were able to get a portion working, but we are still stuck on one thing - I may have a follow up tmrw if you don't mind. Best regards - Ryan

LindonB
11 - Bolide

Sure happy to help if something else comes up!

Labels