Prakash Madhak Prakash Madhak - 1 year ago 66
SQL Question

how to separate Day and Night Record using Mysql Statement

In my SQL database I store date with time stamp for example like this(2015-09-21 18:02:14) I have requirement to get last time(18:02:14) is Day or Night using SQL statement

If you have another idea please share with me. I would like to use it if it fits my requirements.

In my table if have 20 record same date then get only day record how to create query like that

Answer Source

If the day defines from 6am to 6pm, Then

SELECT column
FROM  `tablename` 
WHERE HOUR( column ) 
AND 18;
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download