datetime(): Where is it in the docs?

Started by Jean-Christian Imbeaultover 23 years ago2 messagesgeneral
Jump to latest
#1Jean-Christian Imbeault
jc@mega-bucks.co.jp

I find myself using the datetime() function a lot (as in
to_char(datetime(x), 'MM-DD')) but to be honest I don't really know what
it does.

I've looked in the online interactive docs but can't find a description
of it anywhere, just an example.

Can someone point me to a definition of the function?

Thanks!

Jc

#2Jean-Christian Imbeault
jc@mega-bucks.co.jp
In reply to: Jean-Christian Imbeault (#1)
Re: datetime(): Where is it in the docs?

Henshall, Stuart - WCP wrote:

datetime(x) casts x to type datetime.
I think use of the datetime type is discouraged and timestamp encouraged.

Ok, so what is the encouraged and hopefully fast/efficient way of doing:

to_char(datetime(a_timestamp), 'MM-DD')

would it be to_char('a_timestamp'::timestamp, 'MM-DD') ?

Basically all I want to do is extract the month and day from a
timestamp. I'd used the EXTRACT functions but you can only extract one
part at a time ...

Jc