Reputation: 304
I have unix format date (1414326637) this would be a human readable(2014-10-26 13:30:37).
All that I want is take a part of a human readable date(SUBSTRING(FROM_UNIXTIME(time),11,3)) and take just hours part.
I need filter by hours eg(07:00:00 - 14:59:59) but I cant.
I think this would be with CAST function, but I don't know. I'm trying this and i getting error on INT:
SELECT *,FROM_UNIXTIME(time),CAST(SUBSTRING(FROM_UNIXTIME(time),11,3) AS INT ) as Hours
FROM aulavirtual.mdl_log where action = "view"
and Hours BETWEEN 07 AND 14 order by userid,time
error message
Syntax error, unexpected INT_SYM
Can anyone help ?
Upvotes: 0
Views: 1161
Reputation: 955
Something easier try the HOUR function
SELECT *, HOUR(FROM_UNIXTIME(time)) as Hours
FROM aulavirtual.mdl_log where action = "view"
and HOUR(FROM_UNIXTIME(time)) BETWEEN 07 AND 14 order by userid,time
Upvotes: 2