Announcement

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

  • Write out duration as text

    I am trying to check if anyone has already written some code to write out the duration of an interval as English text, such as in the following example:

    Code:
    clear all
    
    input str244 process str244 duration str244 durationstr
      "Sarah have been working for us" ///
      "02-07-03 02:00:00.000" ///
      "Two years, seven months, three days and two hours."
      "Sarah have been in love with Karl, our enigmatic chief designer" ///
      "02-07-03 01:30:00.000" ///
      "Two years, seven months, three days and an hour and thirty minutes."
    end
    
    label data "https://en.wikiquote.org/wiki/Love_Actually"
    Where durationstr shows what I want from duration. There is no difficulty with head on approach, but I don't want any zeroes of course and perhaps would like to see some human touch (like rounding 6 months to half a year perhaps?)

    I am sure there must be something like this already written. If so, please give me a hint.

    Thank you, Sergiy

  • #2
    Definitely not exactly what you're looking for, but "something like this"

    Code:
    package num2words from http://fmwww.bc.edu/repec/bocode/n
          'NUM2WORDS': module to convert numbers to text

    Comment


    • #3
      Dear Chris, thank you very much for recommending this package. While it is not exactly what solves my problem, but it shows that the solution may be waaay more complex then I originally estimated. Best, Sergiy

      Comment

      Working...
      X