Answer the question
In order to leave comments, you need to log in
How to make a select that selects from the database by timestamp without taking into account the elapsed seconds?
Hello! such a problem, I have a database in it there is a date and time of the timestamp type, I have a script that polls the database every 10 seconds and checks if there is a record for this time, for example, an entry in the database at 16032017 21:30:00, and the script polls at 16032017 21:30:10, so I need him to understand that it is still 2130 and choose this entry for me.
There are several options but none worked for me. Date field of varchar type
('SELECT linkuser,datapost,mylinkpost FROM links WHERE datapost= UNIX_TIMESTAMP(NOW()/60*60)')
('SELECT linkuser,datapost,mylinkpost FROM links WHERE datapost= CAST(UNIX_TIMESTAMP(NOW()/60*60) AS CHAR)')
('SELECT linkuser,datapost,mylinkpost FROM links WHERE datapost= CAST((%s)/60*60 AS CHAR)',(time_now,)) # тут я передаю время сервера в timestamp
('SELECT linkuser,datapost,mylinkpost FROM links WHERE datapost BETWEEN UNIX_TIMESTAMP(NOW())-10 AND UNIX_TIMESTAMP(NOW())+10')
Answer the question
In order to leave comments, you need to log in
make a selection from ...: 10 to ..: 20
but in general, if this is not a Hindu legacy, then I would have thrown you out of the project for this.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question