Skip to main content
replaced http://stackoverflow.com/ with https://stackoverflow.com/
Source Link

This is the issue: I am reading rows with a timestamp column from a table and I need to make sure that the database returns the timestamp with a fixed width. But I am encountering instances where the PostgreSQL database returns the timestamp without the trailing zeros.

The table I am working on contains UUID, Varchar, Smallint and Timestamp. I understand that I can use "to_char" as explained herehere, but what I am really looking for is a way tell PostgreSQL to always return the Timestamp in a given format, regardless of zeros.

Here is an example of the output from the Timestamp column I get, which contains a trimmed Timestamp:

"2014-09-26 17:17:45.999"
"2014-11-26 17:17:46"
"2015-03-26 17:17:46.001"
"2015-04-26 17:17:46.002"
"2015-05-26 17:17:46.003"

This will naturally cause a problem for me since the function that is reading from the database expects to get a timestamp in a given format.

Is there a way to make the PostgreSQL always return a timestamp with a fixed width on SELECT * FROM [table] queries?

Below you see how the fields are created:

"created_UTC" timestamp NOT NULL DEFAULT (now() AT TIME ZONE 'UTC'),
"last_modified_UTC" timestamp NOT NULL DEFAULT (now() AT TIME ZONE 'UTC')

This is the issue: I am reading rows with a timestamp column from a table and I need to make sure that the database returns the timestamp with a fixed width. But I am encountering instances where the PostgreSQL database returns the timestamp without the trailing zeros.

The table I am working on contains UUID, Varchar, Smallint and Timestamp. I understand that I can use "to_char" as explained here, but what I am really looking for is a way tell PostgreSQL to always return the Timestamp in a given format, regardless of zeros.

Here is an example of the output from the Timestamp column I get, which contains a trimmed Timestamp:

"2014-09-26 17:17:45.999"
"2014-11-26 17:17:46"
"2015-03-26 17:17:46.001"
"2015-04-26 17:17:46.002"
"2015-05-26 17:17:46.003"

This will naturally cause a problem for me since the function that is reading from the database expects to get a timestamp in a given format.

Is there a way to make the PostgreSQL always return a timestamp with a fixed width on SELECT * FROM [table] queries?

Below you see how the fields are created:

"created_UTC" timestamp NOT NULL DEFAULT (now() AT TIME ZONE 'UTC'),
"last_modified_UTC" timestamp NOT NULL DEFAULT (now() AT TIME ZONE 'UTC')

This is the issue: I am reading rows with a timestamp column from a table and I need to make sure that the database returns the timestamp with a fixed width. But I am encountering instances where the PostgreSQL database returns the timestamp without the trailing zeros.

The table I am working on contains UUID, Varchar, Smallint and Timestamp. I understand that I can use "to_char" as explained here, but what I am really looking for is a way tell PostgreSQL to always return the Timestamp in a given format, regardless of zeros.

Here is an example of the output from the Timestamp column I get, which contains a trimmed Timestamp:

"2014-09-26 17:17:45.999"
"2014-11-26 17:17:46"
"2015-03-26 17:17:46.001"
"2015-04-26 17:17:46.002"
"2015-05-26 17:17:46.003"

This will naturally cause a problem for me since the function that is reading from the database expects to get a timestamp in a given format.

Is there a way to make the PostgreSQL always return a timestamp with a fixed width on SELECT * FROM [table] queries?

Below you see how the fields are created:

"created_UTC" timestamp NOT NULL DEFAULT (now() AT TIME ZONE 'UTC'),
"last_modified_UTC" timestamp NOT NULL DEFAULT (now() AT TIME ZONE 'UTC')
deleted 43 characters in body
Source Link
ypercubeᵀᴹ
  • 98.6k
  • 13
  • 215
  • 305

This is the issue:
  I am reading rows with a timestamp column from a table and I need to make sure that the database returns the timestamp with a fixed width. But I am encountering instances where the PostgreSQL database returns the timestamp without the trailing zeros.
 

The table I am working on contains UUIDUUID, VarcharVarchar, SmallintSmallint and TimestampTimestamp. I understand that I can use "to_char" as explained here, but what I am really looking for is a way tell PostgreSQL to always return the Timestamp in a given format, regardless of zeros.

Here is an example of the output from the TimestampTimestamp column I get, which contains a trimmed Timestamp:
"2014-09-26 17:17:45.999"
"2014-11-26 17:17:46"
"2015-03-26 17:17:46.001"
"2015-04-26 17:17:46.002"
"2015-05-26 17:17:46.003"

"2014-09-26 17:17:45.999"
"2014-11-26 17:17:46"
"2015-03-26 17:17:46.001"
"2015-04-26 17:17:46.002"
"2015-05-26 17:17:46.003"

This will naturally cause a problem for me since the function that is reading from the database expects to get a Timestamptimestamp in a given format.

Is there a way to make the PostgreSQL always return a timestamp with a fixed width on "SELECT * FROM [table]"SELECT * FROM [table] queries?

Below you see how the fields are created:
"created_UTC" timestamp NOT NULL DEFAULT (now() AT TIME ZONE 'UTC'),
"last_modified_UTC" timestamp NOT NULL DEFAULT (now() AT TIME ZONE 'UTC')

"created_UTC" timestamp NOT NULL DEFAULT (now() AT TIME ZONE 'UTC'),
"last_modified_UTC" timestamp NOT NULL DEFAULT (now() AT TIME ZONE 'UTC')

This is the issue:
  I am reading rows with a timestamp column from a table and I need to make sure that the database returns the timestamp with a fixed width. But I am encountering instances where the PostgreSQL database returns the timestamp without the trailing zeros.
 

The table I am working on contains UUID, Varchar, Smallint and Timestamp. I understand that I can use "to_char" as explained here, but what I am really looking for is a way tell PostgreSQL to always return the Timestamp in a given format, regardless of zeros.

Here is an example of the output from the Timestamp column I get, which contains a trimmed Timestamp:
"2014-09-26 17:17:45.999"
"2014-11-26 17:17:46"
"2015-03-26 17:17:46.001"
"2015-04-26 17:17:46.002"
"2015-05-26 17:17:46.003"

This will naturally cause a problem for me since the function that is reading from the database expects to get a Timestamp in a given format.

Is there a way to make the PostgreSQL always return a timestamp with a fixed width on "SELECT * FROM [table]" queries?

Below you see how the fields are created:
"created_UTC" timestamp NOT NULL DEFAULT (now() AT TIME ZONE 'UTC'),
"last_modified_UTC" timestamp NOT NULL DEFAULT (now() AT TIME ZONE 'UTC')

This is the issue: I am reading rows with a timestamp column from a table and I need to make sure that the database returns the timestamp with a fixed width. But I am encountering instances where the PostgreSQL database returns the timestamp without the trailing zeros.

The table I am working on contains UUID, Varchar, Smallint and Timestamp. I understand that I can use "to_char" as explained here, but what I am really looking for is a way tell PostgreSQL to always return the Timestamp in a given format, regardless of zeros.

Here is an example of the output from the Timestamp column I get, which contains a trimmed Timestamp:

"2014-09-26 17:17:45.999"
"2014-11-26 17:17:46"
"2015-03-26 17:17:46.001"
"2015-04-26 17:17:46.002"
"2015-05-26 17:17:46.003"

This will naturally cause a problem for me since the function that is reading from the database expects to get a timestamp in a given format.

Is there a way to make the PostgreSQL always return a timestamp with a fixed width on SELECT * FROM [table] queries?

Below you see how the fields are created:

"created_UTC" timestamp NOT NULL DEFAULT (now() AT TIME ZONE 'UTC'),
"last_modified_UTC" timestamp NOT NULL DEFAULT (now() AT TIME ZONE 'UTC')
Added field creation text for clarification.
Source Link
Bam
  • 579
  • 1
  • 5
  • 10

This is the issue:
I am reading rows with a timestamp column from a table and I need to make sure that the database returns the timestamp with a fixed width. But I am encountering instances where the PostgreSQL database returns the timestamp without the trailing zeros.

The table I am working on contains UUID, Varchar, Smallint and Timestamp. I understand that I can use "to_char" as explained here, but what I am really looking for is a way tell PostgreSQL to always return the Timestamp in a given format, regardless of zeros.

Here is an example of the output from the Timestamp column I get, which contains a trimmed Timestamp:
"2014-09-26 17:17:45.999"
"2014-11-26 17:17:46"
"2015-03-26 17:17:46.001"
"2015-04-26 17:17:46.002"
"2015-05-26 17:17:46.003"

This will naturally cause a problem for me since the function that is reading from the database expects to get a Timestamp in a given format.

Is there a way to make the PostgreSQL always return a timestamp with a fixed width on "SELECT * FROM [table]" queries?

Below you see how the fields are created:
"created_UTC" timestamp NOT NULL DEFAULT (now() AT TIME ZONE 'UTC'),
"last_modified_UTC" timestamp NOT NULL DEFAULT (now() AT TIME ZONE 'UTC')

This is the issue:
I am reading rows with a timestamp column from a table and I need to make sure that the database returns the timestamp with a fixed width. But I am encountering instances where the PostgreSQL database returns the timestamp without the trailing zeros.

The table I am working on contains UUID, Varchar, Smallint and Timestamp. I understand that I can use "to_char" as explained here, but what I am really looking for is a way tell PostgreSQL to always return the Timestamp in a given format, regardless of zeros.

Here is an example of the output from the Timestamp column I get, which contains a trimmed Timestamp:
"2014-09-26 17:17:45.999"
"2014-11-26 17:17:46"
"2015-03-26 17:17:46.001"
"2015-04-26 17:17:46.002"
"2015-05-26 17:17:46.003"

This will naturally cause a problem for me since the function that is reading from the database expects to get a Timestamp in a given format.

Is there a way to make the PostgreSQL always return a timestamp with a fixed width on "SELECT * FROM [table]" queries?

This is the issue:
I am reading rows with a timestamp column from a table and I need to make sure that the database returns the timestamp with a fixed width. But I am encountering instances where the PostgreSQL database returns the timestamp without the trailing zeros.

The table I am working on contains UUID, Varchar, Smallint and Timestamp. I understand that I can use "to_char" as explained here, but what I am really looking for is a way tell PostgreSQL to always return the Timestamp in a given format, regardless of zeros.

Here is an example of the output from the Timestamp column I get, which contains a trimmed Timestamp:
"2014-09-26 17:17:45.999"
"2014-11-26 17:17:46"
"2015-03-26 17:17:46.001"
"2015-04-26 17:17:46.002"
"2015-05-26 17:17:46.003"

This will naturally cause a problem for me since the function that is reading from the database expects to get a Timestamp in a given format.

Is there a way to make the PostgreSQL always return a timestamp with a fixed width on "SELECT * FROM [table]" queries?

Below you see how the fields are created:
"created_UTC" timestamp NOT NULL DEFAULT (now() AT TIME ZONE 'UTC'),
"last_modified_UTC" timestamp NOT NULL DEFAULT (now() AT TIME ZONE 'UTC')

Source Link
Bam
  • 579
  • 1
  • 5
  • 10
Loading