datepart

SELECT row by DATEPART()

不问归期 提交于 2019-11-27 15:30:44
I need to get rows from the database where the records are of one month. I tried this SELECT: $result = mysql_query("SELECT * FROM my_table WHERE DATEPART('month', date_column)=11"); In database is a lot of rows that have a date in the 11. month, but i do not get any results. Can anyone help me? Thank! There is no DATEPART function in MySQL. Use MONTH(date_column) or EXTRACT(MONTH FROM date_column) instead. SELECT * FROM my_table WHERE MONTH(date_column)=11 If you have an index on date_column and you concern about performance it is better to NOT apply functions over the column. (Be aware that

SELECT row by DATEPART()

我与影子孤独终老i 提交于 2019-11-26 17:14:37
问题 I need to get rows from the database where the records are of one month. I tried this SELECT: $result = mysql_query("SELECT * FROM my_table WHERE DATEPART('month', date_column)=11"); In database is a lot of rows that have a date in the 11. month, but i do not get any results. Can anyone help me? Thank! 回答1: There is no DATEPART function in MySQL. Use MONTH(date_column) or EXTRACT(MONTH FROM date_column) instead. 回答2: SELECT * FROM my_table WHERE MONTH(date_column)=11 回答3: If you have an index