Re: [S] Date Conversion

Robin Regnier (
Thu, 29 Oct 1998 12:33:39 -0800


Firstly, I think the function you want is dates(), not
date(). Using this function requires the syntax
dates("1998/01/01", format="y/m/d").

This means you need to convert your vector from 19980101 to
1998/01/01. I believe there is a section in the user's
guide that shows you how to do this using parse() and
substitute() (don't quote me on this ;) ). I'm really not
up on this stuff right now but one way may be to create
three separate vectors; the first one takes the first 4
characters, the second takes 5-6 characters, and the third
takes the last two. You could then use my.dates <-
paste(x,"/",y,"/",z,sep="") to get the required vector.

I hope this helps by at least giving you a few ideas on how
to tackle the problem.

Robin Regnier
Central Limit Statistical Consulting

-----Original Message-----
From: PT Quants Group Dir <>
To: <>
Date: Thursday, October 29, 1998 11:28 AM
Subject: [S] Date Conversion

> I have date in '19980101' format and I want to convert
in/out from S+.
>date('19980101', format='ymd') does not work
>date( y, 'ymd') results in 980101
>Is there a good way to convert it back and forth? And
especially as a vector rather than looping?
>This message was distributed by
To unsubscribe
>send e-mail to with the
BODY of the
>message: unsubscribe s-news

This message was distributed by To unsubscribe
send e-mail to with the BODY of the
message: unsubscribe s-news