24.2. Converting a Timestamp to a String (strftime) #
Required privileges: Postgres Pro AXE administrator only. For a full list of stored procedures and privileges, refer to Section 12.1.
Execute the following command on the Postgres Pro AXE server:
SELECT strftime(timestamp, 'format') ON CONFLICT DO NOTHING;
Where:
timestamp: The timestamp that must be converted to a string.format: The format of the timestamp.Possible values:
%Y: 4-digit year (2024).%m: Month as a number (01-12).%d: Day of the month (01-31).%H: Hour (00-23).%M: Minute (00-59).%S: Second (00-59).%A: Full weekday name (Monday).%B: Full month name (January).%b: Abbreviated month name (Jan).
Postgres Pro AXE returns the converted timestamp as a TEXT value.
Example 24.2. Executing the strftime Stored Procedure
Converting the current timestamp to a string:
SELECT strftime(NOW(), '%Y-%m-%d %H:%M:%S') AS formatted_time;
Converting timestamps from the orders table:
SELECT
order_id,
strftime(created_at, '%Y-%m-%d') AS order_date,
strftime(created_at, '%H:%M') AS order_time,
strftime(created_at, '%A, %B %d, %Y') AS readable_date
FROM orders;