RE: [SQL] Problems with default date and time - Mailing list pgsql-sql

From Hutton, Rob
Subject RE: [SQL] Problems with default date and time
Date
Msg-id 11EFC736FB68D111B9DD00805FAD7C6D1E0C36@plymartpdc.internal.plymart.com
Whole thread Raw
List pgsql-sql
<p><font size="2">The time and date fields are for reporting purposes while the timestamp is for calculating elapsed
time,so I need all of them.  When I make those changes, I get:</font><p><font size="2">ERROR:  DEFAULT clause type
'timestamp'mismatched with column type 'time'</font><p><font size="2">-----Original Message-----</font><br /><font
size="2">From:Patrik Kudo [<a href="mailto:kudo@partitur.se">mailto:kudo@partitur.se</a>]</font><br /><font
size="2">Sent:Friday, August 13, 1999 10:05 AM</font><br /><font size="2">To: Hutton, Rob</font><br /><font
size="2">Cc:'pgsql-sql@postgresql.org'</font><br /><font size="2">Subject: Re: [SQL] Problems with default date and
time</font><br/><p><font size="2">> "Hutton, Rob" wrote:</font><br /><font size="2">> </font><br /><font
size="2">>  I have created a table with date and time fields by using what I</font><br /><font size="2">> read as
beingthe correct default statements, but I get the date and</font><br /><font size="2">> time the DB was created at
eachinsert instead of the current date and</font><br /><font size="2">> time.</font><br /><font size="2">> |
ord_time                        | time default text 'now'</font><br /><font size="2">> |     8 |</font><br /><font
size="2">>| ord_date                         | date default text 'now'</font><br /><font size="2">> |     4
|</font><br/><font size="2">> | ord_timestamp                    | timestamp default text 'now'</font><br /><font
size="2">>|     4 |</font><p><font size="2">You should not use 'now'. It will be replaced with the current
time.</font><br/><font size="2">Instead use now() and remove "text".</font><p><font size="2">Also, I'd skip the time
anddate fields and exchange timestamp with</font><br /><font size="2">datetime. You would still be able to get the date
andtime from the</font><br /><font size="2">ord_timestamp field using:</font><p><font size="2">select
ord_timestamp::time,ord_timestamp::date from tablename;</font><p><font size="2">The reason I'd use datetime instead of
datetimeis because you</font><br /><font size="2">can't cast from timestamp to time (afaik).</font><p><font
size="2">Hopethis helps.</font><p><font size="2">/Kudo</font> 

pgsql-sql by date:

Previous
From: Tom Lane
Date:
Subject: Re: [SQL] Searching Text Fields - Case Sensitive?
Next
From: "Hutton, Rob"
Date:
Subject: RE: [SQL] Problems with default date and time