Today is my 10,000 days old birthday

February 6, 2014
By

(This article was first published on Data science & Software development » R, and kindly contributed to R-bloggers)

I’ve been calculated my day of 10,000 days old birthday in R since few days ago.
I found that to calculate this in R is quite simple.

My birthday to 10,000 days old birthday:

```> as.Date("1986-09-21") + 10000
[1] "2014-02-06"
```

Birthday to days since my birthday:

```> Sys.Date() - as.Date("1986-09-21")
Time difference of 10000 days
```

Just for reference, below is an R function to convert a birthday to age.

```# Birthday to age
birthday2age <- function(birthday){
td.y <- as.integer(format.Date(Sys.Date(),"%Y"))
td.m <- as.integer(format.Date(Sys.Date(),"%m"))
td.d <- as.integer(format.Date(Sys.Date(),"%d"))
bd.y <- as.integer(format.Date(birthday,"%Y"))
bd.m <- as.integer(format.Date(birthday,"%m"))
bd.d <- as.integer(format.Date(birthday,"%d"))
return(td.y-bd.y-(td.m
> birthday2age("1986-09-21")
[1] 27

Happy birthday with R.
Reference:

var vglnk = { key: '949efb41171ac6ec1bf7f206d57e90b8' };

(function(d, t) {
var s = d.createElement(t); s.type = 'text/javascript'; s.async = true;
var r = d.getElementsByTagName(t)[0]; r.parentNode.insertBefore(s, r);
}(document, 'script'));

Related
ShareTweet

R-bloggers.com offers daily e-mail updates about R news and tutorials on topics such as: Data science, Big Data, R jobs, visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series, trading) and more...

```