I have a question about converting the time value in my data set
(global-analysis-forecast-phys-001-002).
For example the time value is 569004 for (2014-11-29) -- hours since
1950-01-01 00:00:00
How to convert the time value in to date in R ?
I have tried several ways but not work..
> timeval <- 569004
> as.Date(timeval, origin=c("1950-01-01"))
[1] "3507-11-19"
> as.Date(as.POSIXct(timeval, origin="1950-01-01"))
[1] "1950-01-07"
regards,
Eko Susilo
Convert units hours since 1950-01-01 00:00:00 to date
3 messages · Barry Rowlingson, Eko Susilo
On Wed, Dec 31, 2014 at 6:22 AM, Eko Susilo <ekosusilo at live.com> wrote:
as.Date(as.POSIXct(timeval, origin="1950-01-01"))
as.Date works with number of days, so try: > as.Date(timeval/24, origin="1950-01-01") [1] "2014-11-29" as.POSIXct works with seconds, so try: > as.POSIXct(timeval*60*60, origin="1950-01-01") [1] "2014-11-29 12:00:00 GMT" I recommend as.Date if you only want dates and not date-times and your data is really integer days. Barry
Hi Rowlingson thanks you, your command is working well
On 31/12/2014 16:39, Barry Rowlingson wrote:
On Wed, Dec 31, 2014 at 6:22 AM, Eko Susilo <ekosusilo at live.com> wrote:
as.Date(as.POSIXct(timeval, origin="1950-01-01"))
as.Date works with number of days, so try:
> as.Date(timeval/24, origin="1950-01-01")
[1] "2014-11-29" as.POSIXct works with seconds, so try:
> as.POSIXct(timeval*60*60, origin="1950-01-01")
[1] "2014-11-29 12:00:00 GMT" I recommend as.Date if you only want dates and not date-times and your data is really integer days. Barry