[ 
https://issues.apache.org/jira/browse/ARROW-14820?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17491015#comment-17491015
 ] 

SHIMA Tatsuya commented on ARROW-14820:
---------------------------------------

Hi, I was wondering if it was possible to convert timestamp to date in Arrow's 
dplyr pipeline.

Currently, the following seems to work the same `as.Date` and `as_date`, but it 
does not be able to set a timezone.
It would be great if bindings for these functions could be provided.

[https://lubridate.tidyverse.org/reference/as_date.html]
{code:r}
library(arrow, warn.conflicts = FALSE)
library(dplyr, warn.conflicts = FALSE)
library(lubridate)
#>
#> Attaching package: 'lubridate'
#> The following objects are masked from 'package:base':
#>
#>     date, intersect, setdiff, union

df <- tibble::tibble(
  col1 = lubridate::as_datetime("2010-08-03 00:50:50", tz = "Europe/London"),
)

df |>
  arrow_table() |>
  mutate(
    col2 = cast(cast(col1, arrow::timestamp()), arrow::date32()), # 
lubridate::as_date()
    col3 = cast(col1, arrow::date32()) # as.Date()
  ) |>
  collect()
#> # A tibble: 1 × 3
#>   col1                col2       col3
#>   <dttm>              <date>     <date>
#> 1 2010-08-03 00:50:50 2010-08-02 2010-08-03
{code}

> [R] Implement bindings for lubridate calculation functions
> ----------------------------------------------------------
>
>                 Key: ARROW-14820
>                 URL: https://issues.apache.org/jira/browse/ARROW-14820
>             Project: Apache Arrow
>          Issue Type: New Feature
>          Components: R
>            Reporter: Nicola Crane
>            Priority: Major
>




--
This message was sent by Atlassian Jira
(v8.20.1#820001)

Reply via email to