[R] How canI convert date-time to Julian date?

Prof Brian Ripley ripley at stats.ox.ac.uk
Fri Apr 2 17:55:49 CEST 2004


On Fri, 2 Apr 2004, Martina Azaroglu wrote:

> I need some help! I tried everything, but nothing worked!

I am sure you did not try _everything_, but it would have been helpful to 
give some idea of what you were trying.

> I have a vector c with dates in it, in the format "2004-04-01" and i need to
> convert it in the form 
> "04/01/2004" or "01/04/2004" !

In 1.9.0 beta you can do

format(as.Date("2004-04-01"), "%m/%d/%Y")

if you mean American usage for dates.  But that has nothing to do with 
'Julian date'.  In earlier versions

format(as.POSIXlt("2004-04-01"), "%m/%d/%Y")

will do this too.

> How can i do that??

Try help.search?  For example, help.search("date") in 1.8.1 gave

as.POSIXct(base)        Date-time Conversion Functions
format.POSIXct(base)    Date-time Conversion Functions to and from
                        Character
which are the correct pages for my solution above.

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595




More information about the R-help mailing list