exemple requete mysql avec MONTH
SELECT count(id),month(mydate) FROM mydb.mytable
WHERE id= 3
Group by month(mydate)
Equivalent Oracle :
SELECT count(id) , to_char(mydate, 'M') FROM mydb.mytable WHERE id=3 GROUP BY to_char(mydate, 'M')
Year
Parametre | Explication |
YEAR | Year, spelled out in full words |
YYYY | 4-digit year |
YYY | Last 3 digits of year |
YY | Last 2 digits of year |
Y | Last digit of year |
IYY | Last 3 digits of ISO year |
IY | Last 2 digits of ISO year |
I | Last digit of ISO year |
IYYY | 4-digit year, which is based on the ISO standard |
RRRR | This format accepts a 2-digit year, and returns a 4-digit year. If the provided value is between 0 and 49, it will return a year greater than or equal to 2000. If the provided value is between 50 and 99, it will return a year less than 2000 |
Month
Parametre | Explication |
Q | Quarter of year, from 1 to 4. JAN to MAR = 1 |
MM | Month, from 01 to 12. JAN = 01 |
MON | Abbreviated name of month. |
MONTH | Name of month, padded with blanks to length of 9 characters. |
RM | Roman numeral month, from I to XII. JAN = I. |
Week
Parameter | Explication |
WW | Week of year, from 1 to 53. Week 1 starts on the first day of the year, and continues to the seventh day of the year. |
W | Week of month, from 1 to 5. Week 1 starts on the first day of the month and ends on the seventh. |
IW | Week of year, from 1 to 52 or 1 to 53, based on the ISO standard. |
Day
Parametre | Explication |
D | Day of week, from 1 to 7. |
DAY | Name of day. |
DD | Day of month, from 1 to 31. |
DDD | Day of year, from 1 to 366. |
DY | Abbreviated name of day. |
J | Julian day, which is the number of days since January 1, 4712 BC. |
Time
Parametre | Explanation |
HH | Hour of day, from 1 to 12. |
HH12 | Hour of day, from 1 to 12. |
HH24 | Hour of day, from 0 to 23. |
MI | Minute, from 0 to 59 |
SS | Second, from 0 to 59 |
SSSSS | Seconds past midnight, from 0 to 86399. |
FF | Fractional seconds. This uses a value from 1 to 9 after FF, to indicate the number of digits in the fractional seconds (e.g. FF7) |
Indicators
Parametre | Explication |
AM, A.M., PM, or P.M. | Meridian indicator |
AD or A.D | AD indicator |
BC or B.C. | BC indicator |
TZD | Daylight savings information |
TZH | Time zone hour. |
TZM | Time zone minute. |
TZR | Time zone region. |