Sqlx, what is the correct decoder to use for a timestamp?

⚓ rust    📅 2025-06-18    👤 surdeus    👁️ 2      

surdeus

What's the correct decoder to use for a column type postgresql "TIMESTAMP"?

i'm trying to follow the types from sqlx::postgres::types - Rust

using chrono feature

row.get::<chrono::DateTime<chrono::Utc>>("created_at");
// E0277: the trait bound `chrono::DateTime<Utc>: Type<Postgres>` is not satisfied

same for .

Using the "time" feature types, it complains that i need more generics but the manual doesn't mention that signatures:

get::<sqlx::types::time::OffsetDateTime>.get("created_at");
// E0107: supplied 1 generic (expects 2?)

same for primitiveDateTime, etc.

2 posts - 1 participant

Read full topic

🏷️ rust_feed