[R-SIG-Finance] question about time-stamp comparison?

R. Michael Weylandt michael.weylandt at gmail.com
Fri Jan 20 16:59:17 CET 2012


storage.mode(as.POSIXct(123757, origin = "1970-01-01")) # POSIXct
sapply(strptime("1970-01-01 03:43:32.345", format = "%Y-%m-%d
%H:%M:%OS"), storage.mode) #POSIXlt

They are numeric, not character.

Michael Weylandt

On Fri, Jan 20, 2012 at 10:49 AM, Michael <comtech.usa at gmail.com> wrote:
>  Good morning all!
>
> Just wanted to confirm - how do I compare two date-time stamps in the
> following format?
>
> I tried the following and they seem to work fine...
>
> But I am not so sure whether these comparisons are treated as char strings
> and based on alphabetic ordering, or actually R is smart enough to
> auto-recognize these strings and compare based on calendar ordering?
>
> Or maybe calendar ordering is coincidental with alphabetic ordering? I am
> trying to conceive a counter-example...
>
>
> To make it absolutely correct, maybe I should use
>
>
> strptime(date-time-stamp1, "%Y-%m-%d %H:%M:%OS")
>
> vs.
>
> strptime(date-time-stamp2, "%Y-%m-%d %H:%M:%OS")
>
> ? Will that be definitely correct?
>
> Thanks a lot!
>
>> "2011-09-20 12:01:33.386168"< "2011-09-20 12:01:33.386169"
>
> [1] TRUE
>
>> "2011-09-20 12:01:33.386168"< "2012-09-20 12:01:32.386169"
>
> [1] TRUE
>
>        [[alternative HTML version deleted]]
>
> _______________________________________________
> R-SIG-Finance at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-finance
> -- Subscriber-posting only. If you want to post, subscribe first.
> -- Also note that this is not the r-help list where general R questions should go.



More information about the R-SIG-Finance mailing list