[英]SQL Query 3rd term date
INSERT INTO `empleado` VALUES ('100', 'Alfonso', '1999-11-22', '100', '11');
INSERT INTO `empleado` VALUES ('101', 'Encarna', '2001-11-12', '100', '15');
INSERT INTO `empleado` VALUES ('102', 'Paco', '1999-10-16', '101', '12');
INSERT INTO `empleado` VALUES ('103', 'Juan Carlos', '1999-01-12', '101', '10');
That's my Date Type ,I need to select some codes that got into the company in the 3rd term of 1999 这是我的日期类型,我需要选择一些在1999年第3季度进入公司的代码
"select nombre,coddep,fecha_ingreso from
empleado where fecha_ingreso >1999;"
-that was my initial query, but it's wrong since it selects the name
, cod
and datetime >1999
-这是我最初的查询,但是这是错误的,因为它选择了
name
, cod
和datetime >1999
SELECT nombre, coddep, fecha_ingreso
FROM empleado
WHERE YEAR(fecha_ingreso) = 1999 AND QUARTER(fecha_ingreso) = 3
;
This will fetch rows in the 3rd calendar quarter of 1999: 这将在1999年第3季度获取行:
SELECT nombre, coddep, fecha_ingreso
FROM empleado
WHERE fecha_ingreso BETWEEN '1999-07-01' AND '1999-09-30'
If the field is DATETIME rather than DATE, change the second date to 1999-09-30 12:59:59
如果该字段是DATETIME而不是DATE,则将第二个日期更改为
1999-09-30 12:59:59
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.