Announcement

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

  • Dates in mata

    Hi, maybe a very simple question:

    in Stata we have:

    Code:
    . display daily("`c(current_date)'", "DMY")
    22938
    the equivalent output in mata can be:

    Code:
    : "`c(current_date)'"
      20 Oct 2022
    
    
    : stata(`"display daily("`c(current_date)'", "DMY")"')
    22938

    Is there any way to get Stata date notation, not using Stata(), in mata. Maybe using print?

  • #2
    Wow, the documentation for the Mata date() functions in [M-4] Dates would be more helpful if it mentioned that each function takes the same sort of arguments as the Stata function of the same name.
    Code:
    : date("20oct2022","DMY")
      22938
    
    : date("`c(current_date)'","DMY")
      22938

    Comment


    • #3
      William Lisowski , from the documentation, this is explained in [M-5] Dates.

      Code:
      help mata date
      List of all datetime() functions

      ...

      Description

      These functions mirror Stata's date functions; see [D] Datetime.

      Comment


      • #4
        Leonardo Guizzetti -

        Yes, it subsequently became apparent to me that I had misunderstood the intent of "[M-4] Categorical guide to Mata functions". It is just a guide - to get details you need to click on a functioin name link in the leftmost column to find your way to the full documentation in "[M-5] Alphabetical index to Mata functions" (which constutes more than just an index, I feel obliged to point out).

        Thank you for your post, it's good to clean up the misimpression I left before I confuse some later reader.

        Comment


        • #5
          Yes, I can see how that could be confusing if you land at this giant index of all mata functions. There is nothing wrong with a simple reminder in [M-4] Dates that these functions also mirror the Stata function syntax.
          Last edited by Leonardo Guizzetti; 23 Oct 2022, 13:34.

          Comment

          Working...
          X