Announcement

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

  • Extracting last year from $S_DATE

    Hi,
    I have a project that I will automate annually.

    I'm trying to find an efficient way to store last year (the data year) in a local macro. I have a solution but it seems inelegant. Here is my code:

    local year =yofd(date("$S_DATE", "DMY"))
    local year = `year'-1
    di "`year'"

    Is there a better way to do this? is there an $S_YEAR or something similar?

    Thanks in advance!

  • #2
    Code:
    `=real(substr("$S_DATE", -4, 4)) -1'
    Res.:

    Code:
     di `=real(substr("$S_DATE", -4, 4)) -1'
    2020

    Comment


    • #3
      Originally posted by Andrew Musau View Post
      Code:
      `=real(substr("$S_DATE", -4, 4)) -1'
      Res.:

      Code:
      di `=real(substr("$S_DATE", -4, 4)) -1'
      2020
      Thank you!

      Comment

      Working...
      X