Try this (and read R News 4/1): Lines <- "6/4/1992 12:00:00 AM 2/13/1992 12:00:00 AM 6/19/1992 12:00:00 AM 2/11/1992 12:00:00 AM 6/22/1992 12:00:00 AM 10/3/1991 12:00:00 AM 5/12/1992 12:00:00 AM 7/11/1991 12:00:00 AM 2/6/1992 12:00:00 AM 10/4/1991 12:00:00 AM 1/31/1992 12:00:00 AM 6/9/1992 12:00:00 AM 10/9/1991 12:00:00 AM 6/10/1992 12:00:00 AM 7/19/1991 12:00:00 AM 7/18/1991 12:00:00 AM 9/20/1991 12:00:00 AM 8/6/1992 12:00:00 AM 8/12/1992 12:00:00 AM 8/19/1992 12:00:00 AM 7/12/1991 12:00:00 AM 6/5/1992 12:00:00 AM 2/7/1992 12:00:00 AM 7/1/1992 12:00:00 AM 8/7/1992 12:00:00 AM 8/13/1992 12:00:00 AM"
library(chron) DF <- read.table(textConnection(Lines), as.is = TRUE) # they are all dates so we don't need the time component # Here we use chron class since that accepts # mm/dd/yyyy format by default dd <- as.chron(DF[[1]]) dd[1] - dd[2] min(dd) # or use Date class DD <- as.Date(dd) DD[1] - DD[2] min(DD) On Thu, Mar 19, 2009 at 2:20 AM, venkata kirankumar <kiran4u2...@gmail.com> wrote: > Hi all, > I am strugling with date formates and caliculating diferent operations like > different between 2 dates and > getting minimum in vector of dates > > that is i m working with dates in formate "6/22/1992 12:00:00 AM" > and the vector is > > [1] 6/4/1992 12:00:00 AM 2/13/1992 12:00:00 AM 6/19/1992 12:00:00 AM > [4] 2/11/1992 12:00:00 AM 6/22/1992 12:00:00 AM 10/3/1991 12:00:00 AM > [7] 5/12/1992 12:00:00 AM 7/11/1991 12:00:00 AM 2/6/1992 12:00:00 AM > [10] 10/4/1991 12:00:00 AM 1/31/1992 12:00:00 AM 6/9/1992 12:00:00 AM > [13] 10/9/1991 12:00:00 AM 6/10/1992 12:00:00 AM 7/19/1991 12:00:00 AM > [16] 7/18/1991 12:00:00 AM 9/20/1991 12:00:00 AM 8/6/1992 12:00:00 AM > [19] 8/12/1992 12:00:00 AM 8/19/1992 12:00:00 AM 7/12/1991 12:00:00 AM > [22] 6/5/1992 12:00:00 AM 2/7/1992 12:00:00 AM 7/1/1992 12:00:00 AM > [25] 8/7/1992 12:00:00 AM 8/13/1992 12:00:00 AM > > and here i have to get least date (means first initial date) and i have to > get difference between that date to all other dates in vector > > i tried with functins like > > formate() > and round() but its not woking on this formate of data > > can any one help me out to solve this > > > thanks in advance > > [[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. > ______________________________________________ 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.