从DATETIME我只想得到HOUR,我已经尝试了以下方法,但它不起作用:
SELECT DATEPART(HOUR, notificacion_update) as notificacion_hora, notificacion_msj, notificacion_id, notificacion_status
FROM notificacion
WHERE notificacion_status = 1 ORDER BY notificacion_id LIMIT 10;
从DATETIME我只想得到HOUR,我已经尝试了以下方法,但它不起作用:
SELECT DATEPART(HOUR, notificacion_update) as notificacion_hora, notificacion_msj, notificacion_id, notificacion_status
FROM notificacion
WHERE notificacion_status = 1 ORDER BY notificacion_id LIMIT 10;
问题是当你应该使用 Mysql 函数时你正在使用 Sql Server 函数,为此你可以参考以下指南,我给你一个使用 datediff 的例子
那行会发生什么我让它获取值 getdate 将
06/03/2018 15:13:13
根据 sql 和您的 pc,因此仅获取转换具有在 varchar 中转换该日期的属性的时间,代码 108 是允许获取的“世纪”之前设置的日期的时间,在这种情况下,15:13:13
如果您想了解更多信息,请查看此链接。https://msdn.microsoft.com/en-us/library/ms187928(v=sql.120).aspx#Return Types
你可以试试