添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接

PostgreSQL DATE_PART() function

DATE_PART() function

The date_part() function is used to return the part of a date and time.

Syntax:

date_part(text, timestamp) date_part(text, interval)

Return Type: double precision.

PostgreSQL Version: 9.3

Pictorial Presentation of PostgreSQL DATE_PART() function

Example 1: PostgreSQL DATE_PART() function

The example below finds the hour part from the timestamp (date and time specified in the argument) .

code:

SELECT date_part('hour', timestamp '2002-09-17 19:27:45');

Sample Output:

date_part ----------- (1 row)

Example 2: PostgreSQL DATE_PART() function

The example below extracts the months part the given age.

Code:

SELECT date_part('month', interval '3 years 7 months');

Sample Output:

date_part ----------- (1 row)

Previous: CURRENT_TIMESTAMP function
Next: DATE_TRUNC function

Follow us on Facebook and Twitter for latest update.