选择出生日期在35-50岁之间的年龄

时间:2019-03-31 04:04:07

标签: mysql

您好,我想从出生日期列中的30-50岁之间的年龄表中选择数据。

SELECT * FROM
   (SELECT FLOOR((CAST (GetDate() AS INTEGER) - CAST(dob1 AS INTEGER)) / 365.25) AS Age, * 
   from tbl_travelins) as tbl_travelins
WHERE Age >= 30 AND Age < 50

1 个答案:

答案 0 :(得分:1)

尝试使用TIMESTAMPDIFF

SELECT *
FROM tbl_travelins
WHERE TIMESTAMPDIFF(YEAR, dob1, CURDATE()) BETWEEN 30 AND 49;