Re: [R] Convert string to date time

2024-11-26 Thread Rui Barradas
Às 00:53 de 27/11/2024, Sorkin, John escreveu: I am reading a string that has the following form: "2020-08-26_05:15:01" I want to convert the string to a date-time variable. I tired: x <- "2007-02-01_10:10:30" x <- as.POSIXct(x,tz=Sys.timezone()) x but this did not work; the time portion was

Re: [R] Convert string to date time

2024-11-26 Thread David Winsemius via R-help
On 11/26/24 16:53, Sorkin, John wrote: I am reading a string that has the following form: "2020-08-26_05:15:01" I want to convert the string to a date-time variable. I tired: x <- "2007-02-01_10:10:30" That underscore is what's causing your problems. If it needs to stay in there because y

[R] Convert string to date time

2024-11-26 Thread Sorkin, John
I am reading a string that has the following form: "2020-08-26_05:15:01" I want to convert the string to a date-time variable. I tired: x <- "2007-02-01_10:10:30" x <- as.POSIXct(x,tz=Sys.timezone()) x but this did not work; the time portion was ignored. I suspect the problem is the _ between