Assistance Needed with Filtering One Day Data in DateTime Column
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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:
- [date] = DateTimeAdd(DateTimeNow(), -3, "days")
- [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!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Hi @flying008 thank you for the response.
I tried it but still not working for me.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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
