Thread: Date Time Functions - ANSI SQL ?

Date Time Functions - ANSI SQL ?

From
Gonzo Rock
Date:
Curious to know...

Are all the date time functions described in the pgSQL docs are ANSI-SQL or pgSQL extensions?

For Example in the Docs:
------------------------
4.7.1. EXTRACT, date_part

EXTRACT (field FROM source)

The extract function retrieves sub-fields from date/time values, such as year or hour. source is a value expression
thatevaluates to type timestamp or interval. (Expressions of type date or time will be cast to timestamp and can
thereforebe used as well.) field is an identifier (not a string!) that selects what field to extract from the source
value.The extract function returns values of type double precision. The following are valid values: 
 

day The day (of the month) field (1 - 31) 
 SELECT EXTRACT(DAY FROM TIMESTAMP '2001-02-16 20:38:40'); Result: 16

Thanks all,



Re: Date Time Functions - ANSI SQL ?

From
Tom Lane
Date:
Gonzo Rock <GonzoRock@Excite.com> writes:
> Are all the date time functions described in the pgSQL docs are
> ANSI-SQL or pgSQL extensions?

One or the other, yes ;-)

EXTRACT() is ANSI, though I think we may accept a few more field keywords
than the spec mentions.
        regards, tom lane


Re: Date Time Functions - ANSI SQL ?

From
Gonzo Rock
Date:
At 01:39 AM 7/30/01 -0400, Tom Lane wrote:
>Gonzo Rock <GonzoRock@Excite.com> writes:
>> Are all the date time functions described in the pgSQL docs are
>> ANSI-SQL or pgSQL extensions?
>
>One or the other, yes ;-)

Hey Tom,

You Clever guy!

Yes, One or the other!

OK OK! Nothing worse than a programmer who can't be explicit... maybe that's why I struggle so much ;-)

QUESTION:
I'm trying to find a pgSQL source that documents the Non-Standard pgSQL stuff, the stuff that will break when
attemptingto execute against mySQL/Oracle/MSSQLServer etc...
 

Immediately: What about the INHERITANCE capabilities... pretty cool but scarry at the same time. (can you tell I'm
brandnew to SQL and six months late on my current SQL project?)
 

thanks again,


Re: Date Time Functions - ANSI SQL ?

From
Peter Eisentraut
Date:
Gonzo Rock writes:

> I'm trying to find a pgSQL source that documents the Non-Standard
> pgSQL stuff, the stuff that will break when attempting to execute
> against mySQL/Oracle/MSSQLServer etc...

While it would be an appreciated effort to create such a document (and we
already try to document standards-compliance in other places), it would be
of less practical use than it might seem at first.  Most SQL database
packages implement all kinds of functions that are found nowhere near the
SQL standard.  PostgreSQL has copied a number of these and added aliases
and near-aliases in a number of other cases.  We don't all program in ANSI
C or C++ these days either.  What is portable is a bit of a matter of
experience and research, modulo good code organization so you can replace
the unportable parts easily.

-- 
Peter Eisentraut   peter_e@gmx.net   http://funkturm.homeip.net/~peter



Re: Re: Date Time Functions - ANSI SQL ?

From
"Josh Berkus"
Date:
Gonzo,

> > I'm trying to find a pgSQL source that documents the Non-Standard
> > pgSQL stuff, the stuff that will break when attempting to execute
> > against mySQL/Oracle/MSSQLServer etc...

Almost anything you port will break MS SQL Server (7.0 and 6.5, anyway).
SQL Server is so far off the ANSI standard for Dates & Times that no
application may be ported from another server which relies on dates and
time manipulation.

FYI.

-Josh Berkus


______AGLIO DATABASE SOLUTIONS___________________________
                                       Josh Berkus
  Complete information technology      josh@agliodbs.com
   and data management solutions       (415) 565-7293
  for law firms, small businesses        fax 621-2533
    and non-profit organizations.      San Francisco

Attachment