Skip to content
Back to formatted view

Raw Message

Message-ID: <9dd0a87c0901102122q7ea6a984j19e312914d84e655@mail.gmail.com>
Date: 2009-01-11T05:22:24Z
From: Heston Capital
Subject: Convert date/time string to date

I am new to R and am trying to import a text file that contains
date/time and various fields.  I want to sort this matrix by date and
also perform calculations on the date field (difference between two
dates etc).

The format of the string looks as follows:

x<-c("25/2/2003 0:00:00")

I tried:

as.Date(x,format='%d/%m/%y')
[1] "2020-02-25"

Obviously I am doing something wrong here.  I would like to remove the
hh:mm:ss from the end of the string if possible.

Thanks for your help, I have been searching for hours and not getting anywhere.