Hello,
Veerappa Chetty wrote > > HI, > I have to work with data objects. I have trouble. I would like to convert > date to a integer of Julian dates omitting hours, minutes etc. I tried as. > Date and also as.POSIXlt, ct etc. > > Please help me to compute the following difference. I get an "NA" for > output. > > 1/14/2006 0:00:00 AM -1/9/2006 0:00:00 AM > > > Thanks. > Chetty > -- > Professor of Family Medicine > Boston University > Tel: 617-414-6221, Fax:617-414-3345 > emails: chettyvk@,vchetty@ > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help@ 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. > Maybe this is system dependent, but with me, unlike what the help for 'strptime' says, the format character 'H' can be used with the am/pm indicator even if 'p' is present. > x <- c("1/14/2006 0:00:00 AM", "1/9/2006 0:00:00 AM") > # With '%p' in format string > d <- strptime(x, format ="%m/%d/%Y %H:%M:%S %p") > d[1] - d[2] Time difference of 5 days > # Without '%p' > d <- strptime(x, format ="%m/%d/%Y %H:%M:%S") > d[1] - d[2] Time difference of 5 days > > sessionInfo() R version 2.14.1 (2011-12-22) Platform: x86_64-pc-mingw32/x64 (64-bit) locale: [1] LC_COLLATE=Portuguese_Portugal.1252 LC_CTYPE=Portuguese_Portugal.1252 [3] LC_MONETARY=Portuguese_Portugal.1252 LC_NUMERIC=C [5] LC_TIME=Portuguese_Portugal.1252 attached base packages: [1] stats graphics grDevices utils datasets methods base loaded via a namespace (and not attached): [1] tools_2.14.1 And the minus operator works as expected. Hope this helps, Rui Barradas -- View this message in context: http://r.789695.n4.nabble.com/Date-object-tp4576784p4577018.html Sent from the R help mailing list archive at Nabble.com. ______________________________________________ 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.