You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It seems timezone differences are dealt correctly if datetime vectors are used directly (converts to UTC first), but if as.POSIXct is used interactively, timezone is ignored.
library(duckdb, quietly=TRUE)
library(dplyr, quietly=TRUE, warn.conflicts=FALSE)
conn1<- dbConnect(duckdb(), ":memory:")
tbl1<-
tbl(
conn1,
sql("SELECT now() AS now")
) |>
mutate(
now_txt= as.character(now),
compare1=now> as.POSIXct("2025-03-01 18:00:00"), # ignores tzcompare2=now>!!as.POSIXct("2025-03-01 18:00:00") # respects tz
)
tbl1#> # Source: SQL [?? x 4]#> # Database: DuckDB v1.2.0 [root@Darwin 24.3.0:R 4.4.2/:memory:]#> now now_txt compare1 compare2#> <dttm> <chr> <lgl> <lgl> #> 1 2025-03-01 22:13:17 2025-03-01 22:13:17.795+00 TRUE FALSEtbl1|>
show_query()
#> <SQL>#> SELECT#> q01.*,#> CAST(now AS TEXT) AS now_txt,#> now > CAST('2025-03-01 18:00:00' AS TIMESTAMP) AS compare1,#> now > '2025-03-01 23:00:00'::timestamp AS compare2#> FROM (SELECT now() AS now) q01
It seems timezone differences are dealt correctly if datetime vectors are used directly (converts to UTC first), but if
as.POSIXct
is used interactively, timezone is ignored.Created on 2025-03-01 with reprex v2.1.1
Session info
The text was updated successfully, but these errors were encountered: