Why aren't my date-time table operations working as expected?

I'm trying to do downstream calculations on a date-time column, but everything I try throws an error. What's going on?

This is a fairly common issue that users run into when writing queries in Python, and it's usually caused by the existence of a PyObject or Object column existing in the table. Take, for instance, the following query that creates a one-row table with a timestamp at midnight on New Years' Day of 2024:

That worked, so what's the issue? Well, trying a downstream operation on the Timestamp column doesn't work:

Here's part of the error:

This error is caused because there's no query language method epochMillis that exists for a java.lang.Object column type.

The fix for this is simple: do not use methods found in deephaven.time in query strings unless it's absolutely necessary. There are a huge number of available methods in the DateTimeUtils Java class that can do the same thing. That class is auto-imported into the Deephaven Query Language on server startup, so you can call them with no imports at all.

This principle is true for operations outside of date-time libraries as well. For more information on this topic, see the following guides:

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!