In R programming, difference between two dates can be determined by using basic function ** julian() **and passing date object as the parameter in the function. It ignores the leap-seconds.

Syntax:julian(x, origin)

Parameters:

x:represents date object

origin:represents another date object from where difference has to be computed

**Example 1:**

`# Define date objects ` `x <- ` `as.Date` `(` `"2020-06-18"` `) ` `origin_date <- ` `as.Date` `(` `"2015-05-01"` `) ` ` ` `# Difference between dates ` `julian` `(x, origin_date) ` |

*chevron_right*

*filter_none*

**Output:**

[1] 1875 attr(, "origin") [1] "2015-05-01"

**Example 2:**

`# Define date objects ` `x <- ` `as.Date` `(` `"2020-06-18"` `) ` `origin_date <- ` `as.Date` `(` `"1920-06-18"` `) ` ` ` `# Find difference between dates ` `julian` `(x, origin_date) ` |

*chevron_right*

*filter_none*

**Output:**

[1] 36525 attr(, "origin") [1] "1920-06-18"

## Recommended Posts:

- Calculate Time Difference between Dates in R Programming - difftime() Function
- Get Exclusive Elements between Two Objects in R Programming - setdiff() Function
- Compute the Covariance between Two Vectors in R Programming - cov() Function
- Compute the Correlation Coefficient Value between Two Vectors in R Programming - cor() Function
- Add Color Between Two Points of Kernel Density Plot in R Programming - Using with() Function
- Calculate the difference between Consecutive pair of Elements of a Vector in R Programming - diff() Function
- Check if a numeric value falls between a range in R Programming - between() function
- Find positions of Matching Elements between Vectors in R Programming - match() Function
- Check if a Function is a Primitive Function in R Programming - is.primitive() Function
- Intersection of Two Objects in R Programming - intersect() Function
- Check if Two Objects are Equal in R Programming - setequal() Function
- Union of two Objects in R Programming - union() Function
- Performing different Operations on Two Arrays in R Programming - outer() Function
- Merge Two Data Frames by common Columns in R Programming - merge() Function
- Check for Presence of Common Elements between Objects in R Programming - is.element() Function
- Draw Line Segments between Particular Points in R Programming - segments() Function
- Draw a Polygon between specified points in R Programming - polygon() Function
- Plot Arrows Between Points in a Graph in R Programming - arrows() Function
- Create a Range of Colors between the Specified Colors in R Programming - colorRampPalette() Function
- Find position of a Matched Pattern in a String in R Programming – grep() Function

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.