0

I am using postgres sql as my database and i have a column with name event_time. The datatype for this column is time without time zone. i want to set default value for this column as current time with hh:mm:ss format. i have used now. But output i am getting is shown below.

17:39:33.476712

I want the format to be only hh:mm:ss and i want to remove microsecs. So, can the format (hh:mm:ss) be achieved using now() function?

CREATE TABLE public.event_notifications
(
     event_time time(6) without time zone DEFAULT now(),

)
WITH (
    OIDS = FALSE
)
TABLESPACE pg_default;
0

1 Answer 1

2

A time value does not have "a format". Any format you see is applied by the application displaying the values in that column.

If you display the values from inside your application, then use whatever formatting functions your programming language supports.

If you want to format the values in the output of a SQL query, check the configuration of your SQL client if you can adjust the display format for time values.

Or include to_char(event_time, 'hh24:mi:ss') in your query to get the time value as a formatted string.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.