similar to: given a mid-month date, get the month-end date

Displaying 20 results from an estimated 5000 matches similar to: "given a mid-month date, get the month-end date"

2008 Sep 18
1
Adding 1 month to a dataframe column
Dear R experts, I have a problem in modifying one column of a dataframe with a datatime format using a datetime operator. Here is my dataframe A: DATACONT PROVINCIA VALORE 1 2007-12-31 MI 1 2 2007-12-31 PV 2 3 2007-12-31 NA 3 4 2007-12-31 MI 4 5 2007-12-31 RM 5 6 2007-12-31 RM 6 7 2007-12-31 MI 7 8
2007 Jun 13
5
Confusion with sapply
Hi, I have some confusion in applying a function over a column. Here's my function. I just need to shift non-March month-ends to March month-ends. Initially I tried seq.dates, but one cannot give a negative increment (decrement) here. return(as.Date(seq.dates(format(xdate,"%m/%d/%Y"),by="months",len=4)[4]) ) Hence this simple function: > mydate <-
2005 Oct 06
2
isdst
Can someone, please, explain the difference is results below (notice the isdst value) > unlist(as.POSIXlt('2005-7-1')) sec min hour mday mon year wday yday isdst 0 0 0 1 6 105 5 181 1 > unlist(as.POSIXlt(as.Date('2005-7-1'))) sec min hour mday mon year wday yday isdst 0 0 0 1 6 105 5 181 0
2009 Jan 15
4
number of Mondays
dear All, i'm trying to calculate the number of Mondays, Tuesdays, etc that each month within a date range has. I have time series data that spans 60 months and i want to calculate the number of Mondays, Tuesdays, Wed, etc of each month. (I want to control for weekly seasonality but my data is monthly). Is there an easy way to to this in R? or is there a package i could use? i did
2020 Oct 23
2
The presence/absence of `zone` in POSIXlt depending on time zone as a cause of possible inconsistences?
Dear all, I have just detected what seems a minor inconsistence with data types. If one unlists a POSIXlt time with GMT zone gets a numeric vector, since the POSIXlt list has no `zone` element, while if one unlists a POSIXlt time with a non GMT zone (also non specifying tz if the Sys.timezone is not GMT) gets a character vector due to including the `zone` element. > x <-
2011 Mar 10
1
Timezone issue with strftime/strptime and %z and %Z
Hello! I've been trying to get this right for quite a while now and fear there is an easy solution I just don't see. I did not have this problem in Linux, and I searched r-help and Google but did not find a solution, but of course I am grateful for and resources I might not have found our not understood yet. I try to parse a time stamp with time zone. I essentially just want to parse the
2007 Dec 11
3
Wrong length of POSIXt vectors (PR#10507)
Full_Name: Petr Simecek Version: 2.5.1, 2.6.1 OS: Windows XP Submission from: (NULL) (195.113.231.2) Several times I have experienced that a length of a POSIXt vector has not been computed right. Example: tv<-structure(list(sec = c(50, 0, 55, 12, 2, 0, 37, NA, 17, 3, 31 ), min = c(1L, 10L, 11L, 15L, 16L, 18L, 18L, NA, 20L, 22L, 22L ), hour = c(12L, 12L, 12L, 12L, 12L, 12L, 12L, NA, 12L,
2020 Oct 01
3
timezone tests and R-devel
The return value of Sys.time() today with a timezone of US/Eastern is unchanged between 4.0.3-patched and devel, but on devel the following test fails all.equal(x, as.POSIXlt(x)) with x = Sys.time() This means that devel does not complete make tests (failure on tests/reg-tests-2.R) It is entirely possible that it is an error on my end, I use export TZ="US/Eastern" but I have been
2010 Oct 01
3
Converting a dataframe column from string to datetime
Hi, I have a dataframe column of the form v<-c("Fri Feb 05 20:00:01.43000 2010","Fri Feb 05 20:00:02.274000 2010","Fri Feb 05 20:00:02.274000 2010","Fri Feb 05 20:00:06.34000 2010") I need to convert this to datetime form. I did the following.. lapply(v,function(x){strptime(x, "%a %b %d %H:%M:%OS %Y")}) This gives me a list that looks like
2009 Sep 13
3
How to get last day of a month?
Is there any R function to calculate automatically the last day of a particular month? For example "sep2009" should be converted to last day of September of 2009? Thanks -- View this message in context: http://www.nabble.com/How-to-get-last-day-of-a-month--tp25425645p25425645.html Sent from the R help mailing list archive at Nabble.com.
2010 Nov 08
2
finding the last day of the month
Dear R Help, I am trying to get fields showing the last day of each month for a monthly closing project. In order to find the last day of the previous month, I subtract the number of days from the current month. For all months my code works; however, for October, my code doesn't work...it returns 2010-09-*29* instead of 2010-09-*30*. format(strptime("2010-10-31",
2010 Dec 01
1
Changing the day of the month in a date
Hello, I want to change the day of the month in a date object. What I am doing at the moment is: x=as.POSIXlt(x) x$mday=13 x=as.Date(x) Does anybody know if there is a more "natural" (eficient) way to do this Thank you Felipe Parra [[alternative HTML version deleted]]
2010 Dec 27
1
Can't merge on datetime?
x = structure(list(date = structure(list(sec = c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), min = c(0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L), hour = c(0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L), mday = c(1L, 2L, 3L, 4L, 5L, 8L, 9L, 10L, 11L, 12L, 15L, 16L, 17L, 18L, 19L, 22L, 23L, 24L,
2007 May 10
3
Getting the last day of the month.
Hi, Given a date, how do I get the last date of that month? I have data in the form YYYYMM, that I've read as a date using > x$Date <- as.Date(ISOdate(substr(x$YearEnd,1,4),substr(x$YearEnd,5,6),1)) But this gives the first day of the month. To get the last day of the month, I tried > as.Date(as.yearmon(x$Date,frac=0)) But I don't get the last day of the month here. (Tried
2017 May 17
2
R-3.4.0 fails test
After installing R-3.4.0 I ran 'make check' which halted here: $ > tail reg-tests-1d.Rout.fail -n 16 > ## format()ing invalid hand-constructed POSIXlt objects > d <- as.POSIXlt("2016-12-06"); d$zone <- 1 > tools::assertError(format(d)) > d$zone <- NULL > stopifnot(identical(format(d),"2016-12-06")) > d$zone <- "CET" # =
2017 May 17
2
R-3.4.0 fails test
After installing R-3.4.0 I ran 'make check' which halted here: $ > tail reg-tests-1d.Rout.fail -n 16 > ## format()ing invalid hand-constructed POSIXlt objects > d <- as.POSIXlt("2016-12-06"); d$zone <- 1 > tools::assertError(format(d)) > d$zone <- NULL > stopifnot(identical(format(d),"2016-12-06")) > d$zone <- "CET" # =
2003 Aug 13
1
Problems with addition in big POSIX dates
Have you noticed any problems with big dates (>=1/1/2040) in R? Here is the bit of code that I'm having trouble with: > test.date <- strptime("1/1/2040",format="%m/%d/%Y") > > unlist(test.date) sec min hour mday mon year wday yday isdst 0 0 0 1 0 140 0 0 0 > > date.plus.one <- as.POSIXct(test.date) +
2020 Oct 02
2
timezone tests and R-devel
Yes, the potential issue I see is that make check fails when I explicitly set TZ. However, I set it to be the same as what the system reports when I login. Details: The system (RHEL) I am working on has $ strings /etc/localtime | tail -n 1 EST5EDT,M3.2.0,M11.1.0 $ date +%Z EDT $ echo $TZ US/Eastern On Fri, Oct 2, 2020 at 9:48 AM Sebastian Meyer <seb.meyer at fau.de> wrote: > Thank
2007 Sep 27
1
converting numbers in "YYYYMM" format to last calendar day and last exchange trading day of the month
I have a vector that contains month and year in the format YYYYMM (e.g.“200701”, “200702”) I wish to do to things: 1. I need to convert to a date that is the last calendar day of each month. 2. I need to convert this to a date that is the last U.S. stock-exchange trading day of each month. Any advice is appreciated, mymonths <- c(200701, 200702)
2011 Jun 22
2
strange date problem - May 3, 1992 is NA
> is.na(strptime("5/2/1992", format="%m/%d/%Y")) [1] FALSE > is.na(strptime("5/3/1992", format="%m/%d/%Y")) [1] TRUE Any idea what's going on with this? Running strptime against all dates from around 1946, only 5/3/1992 was converted as "NA". Even stranger, it still seems to have a value associated with it (even though is.na thinks