R giving wrong date format - dd/mm/yy at hh/mm format

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

R giving wrong date format - dd/mm/yy at hh/mm format

bluryface12
I have data with  timestamps in the format of dd/mm/yy at hh/mm
Data is in a CSV file so the date formatted as general text reads as "10/4/2017 at 3.00 PM"

I want to add today's date in a new column (eg using sys.time() function) and then subtract from the timestamp to calculate number of days in between. I don't need HH:MM just DD/MM/YYYY

Problem is R wont recognize the timestamp (10/4/2017 at 3.00 PM) as a date. I try formatting the timestamp using as.Date(X, format= "%d/%m/%y") and it returns incorrect date For eg - 10/6/2018 at 10.59 PM becomes "2020-06-10" - Obviously the incorrect year

How can I get R to format "10/4/2017 at 3.00 PM" as a date field in format as DD/MM/YYYY to be able calculate fields)?