How do I extract a list of distinct dates from a table?
I have a table with a date column that contains many repeated dates. How can I get a list of the unique dates?
Use selectDistinct to get the unique dates:
import static io.deephaven.time.DateTimeUtils.parseInstant
// Sample table with many rows and repeated dates across multiple timestamps
startDate = parseInstant("2024-01-15T09:00:00 ET")
source = emptyTable(50).update(
"Timestamp = startDate + (long)(i * HOUR)",
"Date = toLocalDate(Timestamp, 'ET')",
"Value = randomDouble(100.0, 500.0)"
)
// Get distinct dates - reduces 50 rows to just the unique dates
distinctDates = source.selectDistinct("Date")
The distinctDates table now contains only the unique dates from the original table. You can view this table in the Deephaven IDE or use it in further table operations.
This approach works for any column type, not just dates. Use selectDistinct to get unique values from any column in your table.
Note
These FAQ pages contain answers to questions about Deephaven Community Core that our users have asked in our Community Slack. If you have a question that is not in our documentation, join our Community and we'll be happy to help!