Question

I have a very large data set from an instrument which measures depth of a water column, and attaches a date/time stamp to each measurement as a modified Julian Date. Below is a subset of the data. The column is in a data.frame (date) and contains numeric values.

head(date)

Date 
41498.736111,
41498.736123,
41498.736134,
41498.736146,
41498.736157,
41498.736169,

When I transfer the first 2 values (i.e. 41498.736111 and 41498.736123) from the Date column to Excel and format the column to (MM:DD:YYYY hh:mm:ss.000), I get the correct value of 8/12/2013 17:39:59.990 and 8/12/2013 17:40:01.027. This tells me that the origin date for these Julian days is "1899-12-30". I would do this all in Excel, but my dataset is much too large and I will have to do this several times for the next few years, so I'd like to be able to do it all in R.

Is there any way to convert the entire column of these modified Julian Dates to the format "%M%D%Y %H:%M:OS3"?

Was it helpful?

Solution

Yeah, you can just add the number of seconds to the origin:

as.POSIXct('1899-12-30')+(date$Date*24*60*60)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top