Do you know the History of Data Science? READ MORE

Date formula

lolenmile
Level 1
Date formula

Hello dataikers,

I would like to know if one date is part of two distincts dates.

For example, if this date is superior to this date and inferior to this one, then put a 1 in the column or a 0 if it’s not.

 

I know that i have to use a IF function but it doesn’t seems to work !

 

Thank for your help 🙂

0 Kudos
1 Reply
AlexT
Dataiker
Dataiker

Hi,

As mentioned in this thread comparing data with < > is not directly supported. 

You can use something like :

if(diff(date_column.asDate(), '2018-01-01'.asDate('yyyy-MM-dd'), 'seconds') < 0 , 1, 0) && if(diff(date_column.asDate(), '2017-01-01'.asDate('yyyy-MM-dd'), 'seconds') > 0 , 1, 0)

This would return True/False if the date is > 2017-01-01 and < 2018-01-01. 

Screenshot 2021-06-09 at 10.37.25.png

Let me know if this helps. 

0 Kudos