It is really easy using R's date and datetime classes:

st <- as.Date("1998-12-17")
en <- as.Date("2000-1-7")
st0 <- st
# Get the 7th of the month before
st0 <- as.POSIXlt(st); st0$mday <- 7; st0$mon <- st0$mon - 1
st0 <- as.Date(st0)
ll <- seq.Date(st0, en, by="month")
sum(ll > as.Date(st) & ll < en)

and use >= etc depending what you mean by `between'.

On Tue, 15 Feb 2005, Omar Lakkis wrote:

This is a eaeir way to ask my prior question:

I want to caculate how many an exact day of the month there is between
two dates.

For example; How many 7th of the month is there between "1998/12/17"
and "2000/1/7". To make the problem simple, the day of the month (7)
is the day in the 2nd date.

-- Brian D. Ripley, [EMAIL PROTECTED] 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

______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

Reply via email to