Alteryx Designer Desktop Discussions

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

Assistance Needed with Filtering One Day Data in DateTime Column

AKPWZ
8 - Asteroid

I have a date column with a DateTime data type, and I want to filter only one day of data, specifically from '2023-01-01 00:00:00' to '2023-01-01 23:59:59'. However, when using the following two formulas, they don't seem to be working for me:

  1. [date] = DateTimeAdd(DateTimeNow(), -3, "days")
  2. [date] >= DateTimeFormat("2023-01-01 00:00:00", "yyyy-MM-dd HH:mm:ss") AND [date] <= DateTimeFormat("2023-01-01 23:59:59", "yyyy-MM-dd HH:mm:ss")

Could someone please help me understand how to filter for data from a specific day using the filter tool?

 

Thank you!

4 REPLIES 4
flying008
15 - Aurora

Hi, @AKPWZ 

 

1- If your [Date] type is datetime, then:

[Date] >= "2023-01-01 00:00:00" &&
[Date] <= "2023-01-01 23:59:59"

 

2- If not, you need trans the type to datetime by use formula first.

AKPWZ
8 - Asteroid

Hi @flying008 thank you for the response. 
I tried it but still not working for me. 

Hammad_Rashid
11 - Bolide

In Alteryx, you can filter data using the Filter tool and the DateTime functions. However, your current formulas have some issues.

 

Here's the correct approach:

Assuming you have a field named [date] with DateTime data type, you can use the following formula in the Filter tool:

 

DateTimeTrim([date], "day") = DateTimeFormat("2023-01-01", "yyyy-MM-dd")

 

This formula will trim the time component from the [date] field and compare it with the date '2023-01-01'. This way, it will filter for records that fall within that specific day.

 

Make sure to replace [date] with the actual field name in your dataset. Also, note that the DateTimeFormat function is used to convert the constant date '2023-01-01' into the same format as the [date] field.

 

Remember to configure the Filter tool to include records that match the condition.

danilang
19 - Altair
19 - Altair

Hi @AKPWZ 

 

In order to help us help you, can you please provide some more details?  Instead of just saying "It does not work for me", please provide some sample data and possibly some screen shots of the results after applying the techniques suggested by the other people on this post.

 

Thanks

 

Dan

Labels
Top Solution Authors