Number to String Type Conversion #200
-
Hello, I've run through the docs and this discussion forum looking for an answer to this question, so if it already exists I apologize in advance! I'm trying to simply convert the year and month numbers returned from the "time.date" function into a string to create a timestamp I can pass to an http request (Playground here: https://play.openpolicyagent.org/p/uo6ecUpoxn). It doesn't seem there's a built in method to achieve this? Is there a better way than my janky solution in the playground? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hi @meganwolf0 👋 You'd normally use the year := 2022
year_str := sprintf("%v", [year]) Definitely not easy to find unless you know what to look for, so no need to apologize :) |
Beta Was this translation helpful? Give feedback.
Hi @meganwolf0 👋
You'd normally use the
sprintf
built-in function for that:Definitely not easy to find unless you know what to look for, so no need to apologize :)