Get Difference in days between two dates as a number

Tue Apr 04, 2017 8:01 pm

The following R script subtracts two dates and get the difference in days. The dates are in the String format. Thus, the R script has to use date format to convert the strings into dates.

Code:



diff
=as.Date(strptime("2004-02-03""%Y-%m-%d"))-as.Date(strptime("2006-02-03""%Y-%m-%d"))
diffNum=as.numeric(diff)
print(
diff);

 




  Related Posts  to : Get Difference in days between two dates as a number
 find the difference between dates in asp.net     -  
 Formatting dates in mysql     -  
 Comparing Dates in Java     -  
 DYNAMIC DATES IN MYSQL     -  
 convert integer number to octal,hexadecimal number systems     -  
 Validation of php drop down menu of months,days and years     -  
 convert decimal number to octal number     -  
 convert octal number to decimal number     -  
 difference between the >> and >>> operators     -  
 Difference between PHP echo() and PHP print()?     -  

Topic Tags

R Analysis