Important Community update: The process for changing your account details was updated on June 25th. Learn how this impacts your Community experience and the actions we suggest you take to secure your account here.

Alteryx Designer Desktop Discussions

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

How to calculate differences between date and number

acaryasin01
8 - Asteroid

 

Hi,

 

I want to calculate differences between Datetime field and number field.

 

Any help would be appreciated!

 

Thanks in advance,

 

Kind regards,

4 REPLIES 4
IraWatt
17 - Castor
17 - Castor

Hey @acaryasin01,

All the datetime functions are here DateTime Functions | Alteryx Help. Can you be more specific in what you are trying to achieve, it is possible to add or subtract a given number of days or months for example from a date. However you cant for instance do 15 minus 1970-01-01 as that does not make sense. 

Jay-RDC
8 - Asteroid

Hello. Just make sure to check the data type of your the fields you want to calculate the differences. Use a Select Tool and make sure you change the data type to a numeric data type. You can use a formula tool afterwards to calculate the difference.

acaryasin01
8 - Asteroid

Sorry @Jay-RDC  and @IraWatt 

To clarify it a bit more;

I have double data type field and I want to subtract the*is field from the Datetime field.

 

 DaysDateDiff (Desired Column)
 25-8-2022 00:003-8-2022 00:00
 319-10-2022 00:0016-10-2022 00:00
 553-8-2022 00:009-6-2022 00:00
 629-9-2022 00:0023-9-2022 00:00
 1126-10-2022 00:0015-10-2022 00:00
IraWatt
17 - Castor
17 - Castor

Hey @acaryasin01,

Here is one way to do this:

IraWatt_0-1659366052077.png

First convert you date field to a date data type with the date time tool then use the DateTimeAdd function to subtract the days.

 

If your interested in learning more about the datetime functions there is a great cheat sheet Blog here: https://community.alteryx.com/t5/Engine-Works/DateTime-Functions-Cheat-Sheet/ba-p/844353

 

Any questions or issues please ask

Ira Watt
Technical Consultant
Watt@Bulien.com 

 

 

 

Labels