我想将已经插入mysql数据库的php的Year,Month值。我试过这个SQL代码。但它不起作用
$sql = "SELECT EXTRACT(MONTH FROM TIMESTAMP 'paid_time') FROM tbl_pkg_payment_details WHERE client_email='info@n.com'";
paid_time是我的表的时间戳列名。它的确切代码是什么?
答案 0 :(得分:0)
查看MySQL的Date and Time Functions。
如果您想使用月份名称:
$sql = "SELECT MONTHNAME(paid_time) as month, YEAR(paid_time) as year FROM tbl_pkg_payment_details WHERE client_email='info@n.com'";
如果您想使用月份编号:
$sql = "SELECT MONTH(paid_time) as month, YEAR(paid_time) as year FROM tbl_pkg_payment_details WHERE client_email='info@n.com'";