Announcement

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

  • how to display/format dates including minutes?

    Hi,

    I am using the following to download intraday data that are spaced by 30 minutes intervals.
    Code:
    clear all
    local ticker "BTC-USD"
    getsymbols `ticker', fm(1) fd(1) fy(1990) lm(12) frequency(30min) price(adjclose) yahoo clear
    
    * What I have tried but does not work:
    format period %tc

    I am getting the date in the following Stata format and I cannot seem to find the right format to display the date and minutes. Please help. Thanks

    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input double period
    19983
    19984
    19985
    19986
    19987
    19988
    19989
    19990
    19991
    19992
    19993
    19994
    19995
    19996
    19997
    19998
    19999
    20000
    20001
    20002
    20003
    20004
    20005
    20006
    20007
    20008
    20009
    20010
    20011
    20012
    20013
    20014
    20015
    20016
    20017
    20018
    20019
    20020
    20021
    20022
    20023
    20024
    20025
    20026
    20027
    20028
    20029
    20030
    20031
    20032
    20033
    20034
    20035
    20036
    20037
    20038
    20039
    20040
    20041
    20042
    20043
    20044
    20045
    20046
    20047
    20048
    20049
    20050
    20051
    20052
    20053
    20054
    20055
    20056
    20057
    20058
    20059
    20060
    20061
    20062
    20063
    20064
    20065
    20066
    20067
    20068
    20069
    20070
    20071
    20072
    20073
    20074
    20075
    20076
    20077
    20078
    20079
    20080
    20081
    20082
    end

  • #2
    If you want a time variable, you need to create one. In any case, the date variable contains no information on time, so a conversion to time may not be wise (unless you have times held in other variables).

    Code:
    gen double time= clock(string(period, "%td") + "00:00", "DMYhm")
    format time %tc
    Res.:

    Code:
    . l in 1/5
    
         +--------------------------------+
         |    period                 time |
         |--------------------------------|
      1. | 17sep2014   17sep2014 00:00:00 |
      2. | 18sep2014   18sep2014 00:00:00 |
      3. | 19sep2014   19sep2014 00:00:00 |
      4. | 20sep2014   20sep2014 00:00:00 |
      5. | 21sep2014   21sep2014 00:00:00 |
         +--------------------------------+

    Comment

    Working...
    X