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.

Months_Between (Oracle SQL)

neeltjevanas
5 - Atom

Hi everyone,

 

I'm trying to create a workflow in Alteryx that calculates the time between two dates using the same methodology as the MONTHS_BETWEEN function in Oracle SQL (see for example: MONTHS_BETWEEN (oracle.com)).

I'm wondering if there is a built-in function in Alteryx that can do this, or if I need to use a combination of other functions.

 

Any help or suggestions would be greatly appreciated!

 

Thanks in advance.

2 REPLIES 2
binuacs
21 - Polaris

@neeltjevanas you can use the DateTimeDiff() function in Alteryx to find the month difference

 

binuacs_0-1681298476444.png

 

danilang
19 - Altair
19 - Altair

Hi @neeltjevanas 

 

Since Oracle's Months_Between function returns fractional months, you'll need to use a combination of functions to duplicate its functionality

danilang_0-1681323660829.png

The first function returns the number of whole months between the two dates.  The second one calculates the fractional part by bringing the start date into the same month as the end date, determining the number of days between them and dividing this by 31, since the Oracle function assumes 31-day months.  These functions could combined into a single expression, but leaving them separate makes it somewhat easier to see what's happening

 

danilang_2-1681323985301.png

 

Dan

 

 

Labels