Alteryx Designer Desktop Discussions

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

Formula IN-DB Date and Prior Year date

paultno
8 - Asteroid

Is it possible to translate this logic into the Formula IN-DB tool?  I keep running into errors!  Any help is appreciated!

 

if [DATE] < "2017-01-01" then DateTimeAdd([DATE],-366,"days") else DateTimeAdd([DATE],-365,"days") endif
2 REPLIES 2
BenMoss
ACE Emeritus
ACE Emeritus

If you are using the IN-DB formula tool then the formulas you write must be specific to the language and method used by that database, most likely SQL.

 

According to this post it looks like the formula you need is DATEADD()

 

https://docs.microsoft.com/en-us/sql/t-sql/functions/dateadd-transact-sql?view=sql-server-2017

 

You would also have to specify your IF statement in SQL method.

 

https://docs.microsoft.com/en-us/sql/t-sql/language-elements/if-else-transact-sql?view=sql-server-20...

 

Ben

paultno
8 - Asteroid

Thank you, those were helpful sources.  

Labels