• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
count how may records are AM vs. PM

I have a DB with mysql a standard timestamp in the format of 2008-01-23 11:44:16

Can someone help me with the mysql syntax for counting the number of records with a time in the AM and PM. It could be 2 different queries, but I havent been able to figure it out.

[eluser]Armchair Samurai[/eluser]
I'd do it like this - retrieve two records from the table, the first being AM totals and the second PM:
SELECT COUNT(*) AS `times`
FROM `foo`
WHERE HOUR(`bar`) < 12
FROM `foo`
WHERE HOUR(`bar`) >= 12

thanks so much!

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.