We are celebrating the 10-year anniversary of the Alteryx Community! Learn more and join in on the fun here.
Start Free Trial

Alteryx Designer Desktop Discussions

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

Date Time plus one day

AMDalton
5 - Atom

 I need a formula to add one day to a date but keep the time the same. We receive data and midnight has the incorrect date. I have tried:

IF [END_TIME] = '%Y-%m-%d 00:00:00' then DateTimeFormat(DateTimeAdd(DateTimeParse([END_TIME],"%Y-%m-%d"),+1,"days"),'%Y-%m-%d') else [END_TIME] ENDIF

but it just returns the same that already exists.

Below is what I have and what I want

END_TIME
2023-06-15 00:00:00
2023-06-17 05:00:00
2023-06-19 00:00:00
2023-09-14 03:00:00

 

to 

END_TIME
2023-06-16 00:00:00
2023-06-17 05:00:00
2023-06-20 00:00:00
2023-09-14 03:00:00
4 REPLIES 4
Qiu
21 - Polaris
21 - Polaris

@AMDalton 

We can convert the DateTime Value to a String format then filter the data containing "00:00:00" and add one after convering it back to DateTime format.

0321-AMDalton.png

Deano478
12 - Quasar

Hey @AMDalton use the below formula:

DateTimeAdd([END_TIME],1,'days')
Christina_H
14 - Magnetar

I've assumed only the hour is important as none of your examples have minutes or seconds, in which case this works:

IF DateTimeHour([END_TIME])=0 THEN DateTimeAdd([END_TIME],1,"day") ELSE [END_TIME] ENDIF

 

If you need to test the whole time, try this instead:

IF Contains(ToString([END_TIME]),"00:00:00") THEN DateTimeAdd([END_TIME],1,"day") ELSE [END_TIME] ENDIF

AMDalton
5 - Atom

Thanks everyone! Nice observation Christina, yes only hour was relevant. I should have specified that. 

Labels
Top Solution Authors