Date_part Function
This function is useful in set functions and in assuring correct ordering in complex date manipulation. For example, if date_field contains the value 23-oct-1998, then:
date_part('month',date(date_field))
returns a value of 10 (representing October), and
date_part('day',date(date_field))
returns a value of 23.
Months are numbered 1 to 12, starting with January.
Hours are returned according to the 24-hour clock.
Quarters are numbered 1 through 4.
Week 1 begins on the first Monday of the year. Dates before the first Monday of the year are considered to be in week 0. However, if you specify ISO-Week, which is ISO 8601 compliant, the week begins on Monday, but the first week is the week that has the first Thursday. The weeks are numbered 1 through 53.
Therefore, if you are using Week and the date falls before the first Monday in the current year, date_part returns 0. If you are using ISO-Week and the date falls before the week containing the first Thursday of the year, that date is considered part of the last week of the previous year, and date_part returns either 52 or 53.
The following table illustrates the difference between Week and ISO-Week: