To achieve the current time, week, month, quarter, half year, years of conversion, where special attention is to the processing of the week, the IW way of handling logic, if this week has greater than or equal to 4 days, this week belongs to a few years, if less than 4 days, this week belongs to the next year
In 1990/12/31, for example, this day belongs to 199,101 weeks.
SELECT To_number (To_char (sysdate, ' YYYYMMDD ')) as PERIOD,
Sysdate as P_date,
To_number (To_char (sysdate, ' Iyyyiw ')) as P_week,
To_number (To_char (sysdate, ' YYYY ') | | To_char (sysdate, ' MM ')) as P_month,
To_number (To_char (sysdate, ' YYYY ') | | To_char (sysdate, ' Q ')) as P_quarter,
Case
When To_char (sysdate, ' MM ') >= 7 Then
To_number (To_char (sysdate, ' YYYY ') | | ' 2 ')
ELSE
To_number (To_char (sysdate, ' YYYY ') | | ' 1 ')
END as P_half_year,
To_number (To_char (sysdate, ' YYYY ')) as P_year,
Sysdate last_modify_date
From DUAL T
Oracle date converted to weeks, months, quarters, half-yearly, year