Alteryx Designer Desktop Discussions

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

Help in Filtering DATETIME by by time -hours

RafalRazny
5 - Atom

Dear All

 

Would you know if there is a formula/function to filter a DATETIME column on the basis of TIME. In other words I would like to filter occurrences of events, everyday, lets say between 2:00 AM and 5PM in last month. The DATETIME format that I have is YYYY-MM-DD HH:MI:SS.

 

Thank you in advance

5 REPLIES 5
IraWatt
17 - Castor
17 - Castor

Hey @RafalRazny,

This method works:

IraWatt_0-1661942010102.png

You just need to separate out the time variable as a time data type and compare that to a string in a time format.

 

Any questions or issues please ask

Ira Watt
Technical Consultant
Watt@Bulien.com 

 

DanielG
12 - Quasar

@RafalRazny 

 

Within a filter tool, just put this:  DateTimeHour([DTField])>2 and DateTimeHour([DTField])<17  

Where DTField is the field you are filtering on.  

 

No need for a separate formula.

 

Just make sure the DTField is a DateTime datatype, otherwise it will likely return a 0 for the hour.

DataNath
17 - Castor

Could use the DateTimeHour() function. As you want to check between 2am-5pm then you just need this to be >= 2 and < 17 (assuming 24 hour):

 

DataNath_1-1661942227919.png

DataNath_0-1661942215341.png

DanielG
12 - Quasar

Obviously if you want to include 2AM and 5PM you'd change it to >= and <= in there.  😀

RafalRazny
5 - Atom

Thank you! I have used the DateTimeHour function in Filter tool and it works well!. Great job @DanielG and @DataNath!

Labels