s-news
[Top] [All Lists]

Re: Comparing today's date to a particular date

To: "'Dennis Fisher'" <fisher@plessthan.com>, <s-news@lists.biostat.wustl.edu>
Subject: Re: Comparing today's date to a particular date
From: "Max Zhao" <mzhao@homer.att.com>
Date: Tue, 15 Jan 2008 13:45:44 -0500
In-reply-to: <7262F68C-A540-4547-B55B-69542141A26A@plessthan.com>
References: <7262F68C-A540-4547-B55B-69542141A26A@plessthan.com>
Thread-index: AchXoQXgx0RDMMprTCydmnCA2ZnNCAABKfKg

Dennis,

 

I don’t know if there is an easy way to do that. But here is one way if we use the Splus function “date”.

 

#########  Write a function of your own using the Splus function “date”

   mytoday_function() {

      tdate_as.character(date())

      dates(paste(substring(tdate, 5, 10),substring(tdate, 25),sep=" "), format="mon dd yyyy")

   } 

 

########  You can compare the dates using the following command

as.numeric(mytoday())<as.numeric(dates("01/14/2008"))

as.numeric(mytoday())<as.numeric(dates("01/16/2008"))

 

Hope this helps.

Max

 

 


From: s-news-owner@lists.biostat.wustl.edu [mailto:s-news-owner@lists.biostat.wustl.edu] On Behalf Of Dennis Fisher
Sent: Tuesday, January 15, 2008 1:03 PM
To: s-news@lists.biostat.wustl.edu
Subject: [S] Comparing today's date to a particular date

 

Colleagues,

 

I would like to compare today's date to a particular date, e.g., next January 1.  In R, you could do something like:

 

            as.numeric(Sys.Date()) < as.numeric(as.Date("2009-01-01"))

 

However, fewer time-related commands are available in S-Plus.  Does anyone have a quick fix to this?

 

Dennis

 

 

Dennis Fisher MD

P < (The "P Less Than" Company)

Phone: 1-866-PLessThan (1-866-753-7784)

Fax: 1-415-564-2220

www.PLessThan.com

 

<Prev in Thread] Current Thread [Next in Thread>