Date format conversion

Dear Team,

since many days im trying to run decision tree algorithm. But i couldnt change the date to dummy variable. because of the format Y,M,D, H:M:S. but i want to change the format to YMD.

my questions are?

  1. is it necessary to make dates into dummy variables
  2. how to convert all my dates (10000 dates of x variable) format Y,M,D, H:M:S. to YMD .


  1. Sometimes you want date as a dummy, sometimes you don't. Impossible to tell without a str(YOUR_OBJECT) and a model

Here's how to convert a single date

example <- now()

How to convert multiple dates depends on your object. Assuming it's a tibble with the column name datetime, all you have to do is

YourNewObject <- YourOldOblect %>% mutate(datetime = date(datetime)

A gentle admonition. Answers without complete information are likely to go unanswered. See FAQ: What's a reproducible example (`reprex`) and how do I do one?.

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