How to convert text dates to excel dates

Hi, I have an R script that imports a couple of csv files, merges them and does all sorts of manipulations. Mostly i use SQLDF (sqlite) as I am a competent SQL coder and not yet competent in R.
All this works fine apart from the date fields which output as text. Sqlite doesn't have a date type. This causes a problem as the PowerQuery that then imports the output from my R program expects dates to be numerics.

I have found how to convert excel dates numbers to dates in R, using as.date, but I need the opposite.

Any ideas?

Thanks

Andrew

Something like this?

Hi,
I use the janitor package. It has specific functions to deal with excel dates.
The convert_to_date() will do exactly that.

[https://cran.r-project.org/web/packages/janitor/vignettes/janitor.html#fix-dates-stored-as-serial-numbers-with-excel_numeric_to_date](http://Link to janitor function documentation.)

2 Likes

Hi William, That looks like the kind of thing I was after. Thanks Andrew

That looks interesting. I will look into it. Cheers Andrew

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.