- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to find the date after a number of days in R?
In our daily life, often we want to know what will be date after some number of days. This is also required in professional life, especially in those professions where we work on projects and have tight deadlines. To find the date after a number a certain number of days we can just use plus sign after reading the date with as.Date.
Example
> as.Date("2001-01-01")+30 [1] "2001-01-31" > as.Date("2020-06-30")+30 [1] "2020-07-30" > as.Date("2020-06-30")+50 [1] "2020-08-19" > as.Date("2020-06-30")+100 [1] "2020-10-08" > as.Date("2020-06-30")+120 [1] "2020-10-28" > as.Date("2020-06-30")+15 [1] "2020-07-15" > as.Date("2020-06-30")+45 [1] "2020-08-14" > as.Date("2020-06-30")+40 [1] "2020-08-09" > as.Date("2020-12-25")+20 [1] "2021-01-14" > as.Date("2020-12-25")+300 [1] "2021-10-21" > as.Date("2020-12-25")+125 [1] "2021-04-29" > as.Date("2020-12-25")+80 [1] "2021-03-15"
We can also use / to read the dates as shown below −
> as.Date("2020/12/25")+25 [1] "2021-01-19" > as.Date("2020/12/25")+200 [1] "2021-07-13" > as.Date("2020/12/25")+52 [1] "2021-02-15" > as.Date("2020/12/25")+90 [1] "2021-03-25" > as.Date("2020/12/25")+500 [1] "2022-05-09" > as.Date("2020/12/25")+1000 [1] "2023-09-21"
- Related Articles
- How to subtract number of days from a date to get the previous date in R?
- How to find the difference in number of days between two date columns of an R data frame?
- How to add number of days to JavaScript Date?
- How to find the number of days and number of weeks between two dates in R?
- Python Program to find out the price of a product after a number of days
- Get the number of days between current date and date field?
- How to add number of business/working days or hours to a date in Excel?
- PHP program to find number of days in every week between two given date ranges
- MySQL query to fetch date records greater than the current date after adding days with INTERVAL?
- Is there a way to subtract number of days from a date in MySQL?
- How to find out number of days in a month in MySQL?
- How to find the number of days in a month of a particular year in Java?
- How to subtract days from a date in JavaScript?
- How to convert days in a week to number in R data frame column?
- How to find the mean of a column grouped by date in R?

Advertisements