working with timestamps

I have a table with epochtime (Unix-Time) in one row. Now I want to select data, with certain date range. I tried: SELECT * FROM `WasserstandAllLive` WHERE `epochtime` between DATEDIFF(second,{d '1970-01-01'},'2024-10-20') and DATEDIFF(second,{d '1970-01-01'},('2024-10-19') ORDER BY `epochtime`

But it doesnot work. How is it correct?

Answer Answered by Ian Gilfillan in this comment.

The DATEDIFF function requires two parameters (date or date and time) and returns a value in days of expr1-expr2, so your syntax is invalid.

You don't specify your structure, or exactly what you're trying to do, but assuming epochtime contains a unix time value, and you're just trying to return values between the two dates, something like SELECT * FROM WasserstandAllLive WHERE FROM_UNIXTIME(epochtime) BETWEEN '2024-10-19 00:00:00' AND '2024-10-20 00:00:00'; should work.

Comments

Comments loading...
Content reproduced on this site is the property of its respective owners, and this content is not reviewed in advance by MariaDB. The views, information and opinions expressed by this content do not necessarily represent those of MariaDB or any other party.