Couple of choices depending on what you want to do with the data:

> x <- as.POSIXct("05/16/2008", format="%m/%d/%Y")  # if you want to use the
date
> format(x, "%d") # day
[1] "16"
> format(x, "%m") # month
[1] "05"
> format(x, "%Y") # year
[1] "2008"
> # or
> y <- strsplit("05/16/2008", '/')  # to just get the characters
> y
[[1]]
[1] "05"   "16"   "2008"
>


On Mon, Jun 22, 2009 at 11:36 AM, Jack Luo <jluo.rh...@gmail.com> wrote:

> Hi,
>
> I have a simple question, suppose I have the date "05/16/2008", what would
> be the command to get the month, day and year?
>
> Thanks,
>
> -Jack
>
>        [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html<http://www.r-project.org/posting-guide.html>
> and provide commented, minimal, self-contained, reproducible code.
>



-- 
Jim Holtman
Cincinnati, OH
+1 513 646 9390

What is the problem that you are trying to solve?

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to