Convert Time value to time string

I am trying to convert a Time value, defined as string parameter, to a time format and I am having trouble with the Time_to_str function.

e.g.

Parameters

- TIME defined as String with the value 142789657

- TIME_STR defined as String

If I use in a Calc block the following expression:

'/TIME_STR.CV' := TIME_TO_STR (%A, '/TIME')

the result is an empty parameter. It seems that the parameter '/TIME' is not in the right format. What can I do to make thjis work?

  • Put double quotes around the %A in your expression.

    Not sure how your TIME parameter is getting set but you can just use the below and it should work for you
    '/TIME_STR.CV' := TIME_TO_STR("%A", TIME('$time_format:Local'));
  • In reply to Matt Stoner:

    Thanks. Yes, I forgot to include the quotes.
    What I really what I need to do is add x seconds to the current time.
    If I use the TIME('$time_format:Local') I get the current time as a string.
    I can then write it to an integer parameter and use it to sum whatever value I want.
    I then convert the integer parameter to a string parameter, but when I put it back in the TIME_TO_STR("%A", new string parameter) I don't get any value out of the function.
  • Joao,
     
    Copied the expressions that I am successfully using.
     
     
    Chris
     
     
  • In reply to Chris Kominar:

    Thanks.
    It's ok, but now the question is how can I do the following operation:

    (*t is an arbritary value in seconds*)

    t := 3600 x 7.5;

    (*TIME_STAMP2 is a date in the future that is the sum of CURRENT_TIME + t*)

    '/TIME_STAMP2' := time_to_str("%A", '/CURRENT_TIME' + t)
  • Your TIME parameter needs to be a 32-bit unsigned integer, not String.