There is a table where the TS column is a DateTime type. And it fills up every 10 seconds approximately. How can I make a request for the data to be shown only every minute?

Closed due to the fact that the essence of the question is not clear to the participants of VenZell , atwice , Shilgen , Nofate ♦ Apr 16 '15 at 8:56 .

Try to write more detailed questions. To get an answer, explain what exactly you see the problem, how to reproduce it, what you want to get as a result, etc. Give an example that clearly demonstrates the problem. If the question can be reformulated according to the rules set out in the certificate , edit it .

  • What does "just for every minute" mean? - ArcherGodson
  • 2
    What kind of SQL do you have? - Drac5
  • one
    I would like to see an example of the data, and what you want to get. - msi
  • I suspect that the question in translation means: "How to group records by the minute?" , did you mean it? - IVsevolod

3 answers 3

So?

... WHERE TS BETWEEN DATE_FORMAT(NOW(),'%Y-%m-%d %H:%i:00') AND DATE_FORMAT(NOW() + INTERVAL 1 MINUTE,'%Y-%m-%d %H:%i:00') 

the current minute .. you can simply do just past:

 ... WHERE TS BETWEEN DATE_FORMAT(NOW() - INTERVAL 1 MINUTE,'%Y-%m-%d %H:%i:00') AND DATE_FORMAT(NOW(),'%Y-%m-%d %H:%i:00') 
  • . SELECT *, DATE_FORMAT ( TS , '% Y-% m-% d% H:% i: 00') AS TS_minute FROM table GROUP BY TS_minute - istem
  • In firebird there is [DATEADD ()] [1] [1]: firebirdsql.su/doku.php?id=dateadd - ArcherGodson

Is there a creation date or modification date? You can filter by these dates.

  • There are no such fields. - zerpico

Try this:

 SELECT * FROM `table_name` WHERE `TS` > NOW() - INTERVAL 1 MINUTE 
  • one
    Rave. Is there a command "INTERVAL 1 MINUTE"? - zerpico
  • one
    @Pandacun, nonsense - this is what you do not know. I was talking about MySQL, and if you use something else, you don’t need to “snort”, but specifically indicate in the question. - Deonis
  • There is. And check or google? There you can both in minutes and in hours - Node_pro '11
  • Of course there is a SELECT (NOW () + interval 1 minute); + --------------------------- + | (NOW () + interval 1 minute) | + --------------------------- + | 2013-03-05 15:13:10 | + --------------------------- + - ArcherGodson
  • After all, you were asked what kind of subd you use - you are silent! MySQL has this design. Moreover, without checking, write that this is nonsense! - null