s-news
[Top] [All Lists]

Re: Converting a given double to a date

To: "Smeets, S (Sjoerd)" <S.Smeets@Interpolis.nl>, s-news@lists.biostat.wustl.edu
Subject: Re: Converting a given double to a date
From: Tony Plate <tplate@blackmesacapital.com>
Date: Tue, 28 Sep 2004 10:11:03 -0600
In-reply-to: <57B39CA14745CD4BA605CBE29FD033E0029685E2@til-ex-04.ini.cor p>
References: <57B39CA14745CD4BA605CBE29FD033E0029685E2@til-ex-04.ini.corp>
Something like one of the following should do the trick.

> x <- c(20010223, 20040530)
> timeDate(as.character(x), in.format="%4Y%2m%2d")
[1] 2001/02/23 2004/05/30
> timeCalendar(y=floor(x/10000), m=floor((x %% 10000) / 100), d=x %% 100)
[1] 2001/02/23 2004/05/30
>

A gotcha here is time zones.  If you are using something other than:

> options("time.zone")
$time.zone:
[1] "GMT"

then you need to be careful with time zones -- the dates might not be getting the time of day that you want.

-- Tony Plate

At Tuesday 02:06 AM 9/28/2004, Smeets, S (Sjoerd) wrote:

Hi,

I have got a vector with dates and they are as follows:

20010223
20040530

So first the year then the month and day. Now I want to convert these dates to s-plus dates? How can this be done? When I do it using the GUI I get years like 4713. But it has to change in 23/02/2001.

Kind regards

Sjoerd Smeets

================================================
De informatie opgenomen in dit bericht kan vertrouwelijk zijn en
is uitsluitend bestemd voor de geadresseerde. Indien u dit bericht
onterecht ontvangt, wordt u verzocht de inhoud niet te gebruiken en
de afzender direct te informeren door het bericht te retourneren.
================================================
The information contained in this message may be confidential
and is intended to be exclusively for the addressee. Should you
receive this message unintentionally, please do not use the contents
herein and notify the sender immediately by return e-mail.
<Prev in Thread] Current Thread [Next in Thread>