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

Dragoș Moldovan-Grünfeld commented on ARROW-14820:
--------------------------------------------------

Hi [~eitsupi],

Thanks for filing the ticket. Once [PR 
12433|https://github.com/apache/arrow/pull/12433] is merged you will be able to 
use `date()` to extract the date component of a timestamp. {{as.Date()}} is 
covered by the same pull request.

The snippet of code below should work once we merge the PR. Please note 
{{base::as.Date()}} by default assumes you want the date in UTC :
{code:r}
library(dplyr)
library(lubridate)
library(arrow)

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

# lubridate
df %>% 
  mutate(x = as_date(col1),
         y = as.Date(col1))
#> # A tibble: 1 × 3
#>   col1                x          y         
#>   <dttm>              <date>     <date>    
#> 1 2010-08-03 00:50:50 2010-08-03 2010-08-02

# arrow
df %>% 
  arrow_table() %>% 
  mutate(x = date(col1),
         y = as.Date(col1)) %>% 
  collect()
#> # A tibble: 1 × 3
#>   col1                x          y         
#>   <dttm>              <date>     <date>    
#> 1 2010-08-03 00:50:50 2010-08-03 2010-08-02
{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