Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Compare date/time variables

    With the following time/date variables as formatted below, how can I extract only the times (disregarding the dates) in a way that allows me to compare the times? I.e., test if one time comes before/after the other.





    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input float timevar1 double timevar2
    1.8855085e+12 54000000
    1.8855085e+12 36000000
     1.917198e+12 21600000
     1.917198e+12 46800000
     1.886614e+12 23400000
     1.886614e+12 54000000
    1.8858352e+12 21600000
    1.8858211e+12 50400000
    1.8827201e+12 18000000
    end
    format %tcHH:MM:SS timevar1
    format %tcHH:MM_AM timevar2

  • #2
    You can extract the hour and minute using the -hh()- and -mm()- functions, respectively. See

    Code:
    help datetime
    Note that datetime variables should always be stored as double.

    Comment

    Working...
    X