Converting date time to date

Dears hope you can help,

i am try to convert date time to date i used the below :slight_smile:

#to convert date time to date

EcommerceDate <- ECommerce %>%
mutate(Date=as.Date(ECommerce$InvoiceDate, format = "%m/%d/%Y %I:%M"))

create Month year date

EcommerceMonthYear <- EcommerceDate %>%
mutate(Month_Year=strftime(Ecommerce2$Date,format="%Y/%m"))

XXX <- Ecommerce_Clean2 %>% group_by(Month_Year) %>% summarise(count=n())

XXX

A tibble: 16 x 2

Month_Year count

1 0201/10 43920
2 0201/11 61632
3 0201/12 19464
4 2010/12 22016
5 2011/01 34306
6 2011/02 27105
7 2011/03 35803
8 2011/04 29096
9 2011/05 36164
10 2011/06 35977
11 2011/07 38645
12 2011/08 34483
13 2011/09 49261
14 2011/10 15384
15 2011/11 21737
16 2011/12 25111

I am getting "0201" in the year part, however there is no "0201" in my invoicedate field.

Please advice

It's hard to tell what's up without knowing what the input datetime data looks like.

Could you please turn this into a self-contained reprex (short for reproducible example)? It will help us help you if we can be sure we're all working with/looking at the same stuff.

install.packages("reprex")

If you've never heard of a reprex before, you might want to start by reading the tidyverse.org help page. The reprex dos and don'ts are also useful.

There's also a nice FAQ on how to do a minimal reprex for beginners, below:

What to do if you run into clipboard problems

If you run into problems with access to your clipboard, you can specify an outfile for the reprex, and then copy and paste the contents into the forum.

reprex::reprex(input = "fruits_stringdist.R", outfile = "fruits_stringdist.md")

For pointers specific to the community site, check out the reprex FAQ.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.