Advent of Code is back! Unwrap daily challenges to sharpen your Alteryx skills and earn badges along the way! Learn more now.
Free Trial

Alteryx Designer Desktop Discussions

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

Formula Help - If Time < hh:mm:ss

dmill8023
6 - Meteoroid

I am trying to build a formula for what day we record shipping product.  If we ship product before 21:00:00 we count that as same day and if it ships after 21:00:00 it would count towards the following day.  I have the following built but am getting [Null] in my output.  Not sure what I am missing - DateTime_Out is Time type and SHIPMENT_DATE is Date Type if that helps.

 

IF [DateTime_Out] < "21:00:00" THEN DateTimeAdd(DateTimeParse([SHIPMENT_DATE],"%d-%b-%y"),+1,"days") else [SHIPMENT_DATE] ENDIF

 

All suggestions / insights are appreciated!

5 REPLIES 5
ChrisTX
16 - Nebula
16 - Nebula

In your Formula tool, what is the output data type for the new field you are creating?

 

If it's a Date, you don't need the DateTimeParse.  Just use:

 

DateTimeAdd([SHIPMENT_DATE], 1, "days")

 

Chris

dmill8023
6 - Meteoroid

The output data type is date - tried using the following and still getting null in new column.  IF [DateTime_Out] < "21:00:00" THEN DateTimeAdd([SHIPMENT_DATE],1,"days") else [SHIPMENT_DATE] ENDIF Formula Capture.PNG

 

DawnDuong
13 - Pulsar
13 - Pulsar

hi @dmill8023 

My guess is there is some confusion between Date, DateTime and Time formats between the various fields.

If we impose a Time format on a Date field (or vice versa impose a DateTime or Date format on a Time field), the value will be [null].

TimeFormats.PNGDateformats.PNG

Dawn.

 

ChrisTX
16 - Nebula
16 - Nebula

In the Results window screen shot below, the field data types are Date, Time, Date, String

 

The formula testing the Time field, and adding 1 to the Date field seems to be working  OK.

 

ChrisTX_0-1634586291364.png

 

Chris

 

DawnDuong
13 - Pulsar
13 - Pulsar

i suspect the issue is with the field [Shipment date]. If that is not of the right type, the output is null, even then the "if conditions" part works.

Labels
Top Solution Authors