Skip to content

Date calculations

6 messages · P. Hénaff, Diethelm Wuertz, David Kane +3 more

#
P. H?naff wrote:

            
in Rmetrics use:

myFinCenter = "GMT" # for daily dates
timeDate("2005-04-03")
[1] "GMT"
[1] [2005-04-03]
timeDate("2005-04-03") + 3*24*3600
[1] "GMT"
[1] [2005-04-06]

# Living in Zurich
myFinCenter = "Zurich"
timeDate("2005-04-03")
[1] "Zurich"
[1] [2005-04-03 02:00:00]
timeDate("2005-04-03") + 3*24*3600
[1] "Zurich"
[1] [2005-04-06 02:00:00]

# Use for Daily dates:
timeDate("2005-04-03", zone = "Zurich")
[1] "Zurich"
[1] [2005-04-03]
timeDate("2005-04-03", zone = "Zurich") + 3*24*3600
[1] "Zurich"
[1] [2005-04-06]
It is no longer necessary to specify the timezone. This holds since the 
latest
version 221.10065 (download it from CRAN).
For daily dates just be sure that the time zone where you recorded the data
(zone=...) and the time zone where you use your data (FinCenter=..) are
specified as the same. both GMT, or the financial Center where you are
living and your operating system's time zone environment variable is set.
(Note, this is not necessarily the same timezone your clock works on your
windows box, which doesn't make use of the Windows time zone environment
variable TZ).

Please let me know if you have further questions (or problems) with 
timeDate()
Diethelm
#
Perhaps date() is what you want. That's what we use for financial
applications in which h/m/s does not matter.

Dave Kane
#
On Wed, 22 Mar 2006 00:38:20 -0600 P. H?naff wrote:

            
In that case I would recommend to go with the "Date" class available in
base R, e.g.
  as.Date("2005-04-03") + 0:10
which should be rather self-explanatory.

The package zoo provides time series infrastructure where the time
information can be stored in "Date" (or virtually any other class).
  library("zoo")
  z <- zoo(rnorm(11), as.Date("2005-04-03") + 0:10)
  plot(z)

hth,
Z
#
If you use the date or survival libraries, you can do something like:
as.date("01/10/2001", "mdy"), as well as as.date(14985) -- a julian
argument. You can also go back and forth between julians and numeric vectors
with mdy.date and date.mdy.

Steve Miller 

-----Original Message-----
From: r-sig-finance-bounces at stat.math.ethz.ch
[mailto:r-sig-finance-bounces at stat.math.ethz.ch] On Behalf Of Mahesh
Krishnan
Sent: Wednesday, March 22, 2006 10:31 AM
To: r-sig-finance at stat.math.ethz.ch
Subject: Re: [R-sig-finance] Date calculations

Henaff,

I have found the following to be of use when using Date manipulations.

Example:

 tDate <- as.Date("03/22/2006", "%m/%d/%Y") ;

tDate +1    ## will give the update 03/23/2006 and so on..

Best regards,

Mahesh.

ps: fyi: the capital Y in as.Date refers to a 4 digit year representation
On 3/21/06, P. Hinaff <patrick.henaff at kermatheano.com> wrote:
POSIXct