Re: Convert date and time colums to datetime

From: Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>
To: Rich Shepard <rshepard(at)appl-ecosys(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re: Convert date and time colums to datetime
Date: 2025-10-19 14:56:57
Message-ID: 755cee02-f2c5-45b9-b90e-db80f2cd02fe@aklaver.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 10/19/25 07:53, Adrian Klaver wrote:
> On 10/19/25 07:43, Rich Shepard wrote:
>> The database has a table with separate date and time columns.
>>
>> 1. Are there benefits to merging the two into a single timestamp column?
>
> 1) One less column to fetch from.
>
> 2) If you really need a timestamp the work is already done, instead of
> building on the fly.
>
>>
>> 2. If so, how would I do this? (Reading date/time operators and functions
>> doc page hasn't shown me one.)
>
> select ('10/19/2025'::date + '07:50'::time)::timestamptz;
>
> timestamptz
> ------------------------
>  2025-10-19 07:50:00-07

Should have added in previous post, the above assumes your current date
and time values are from the server timezone.

>
>>
>> TIA,
>>
>> Rich
>>
>>
>>
>
>

--
Adrian Klaver
adrian(dot)klaver(at)aklaver(dot)com

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Rich Shepard 2025-10-19 16:35:39 Re: Convert date and time colums to datetime
Previous Message Adrian Klaver 2025-10-19 14:53:56 Re: Convert date and time colums to datetime