I was trying to get a data between yesterday’s noon to today’s noon.
There are two columns for time, one is called in_date(date type) and the other one is called in_time(time type).
At first, i tried to put those values in between values, but I did know what to put time values for between.
This is what i did
SELECT b.filepath, b.filename, a.indate, a.intime
FROM tb_st AS a
INNER JOIN tb_cont AS b ON a.stuidx = b.stuidx
WHERE (a.indate BETWEEN '2023-04-26' AND '2023-04-27')
then I decided to combine in_date and in_time but, I failed again….it says unknown column ‘newdate’ in ‘where clause’
This was my second try..
SELECT CAST(a.indate AS DATETIME) + CAST(a.intime AS DATETIME) AS newdate,
b.filepath, b.filename, a.indate, a.intime
FROM tb_st AS a
INNER JOIN tb_cont AS b ON a.stuidx = b.stuidx
WHERE newdate BETWEEN '20230426120000' AND '20230427120000'
what is the best way to get a result for this…?
2
Answers
It doesn’t need to be complicated.
in_date
andin_time
2023-04-26 12:00
to2023-04-27 11:59:59
So the WHERE clause can be like:
You can try it as: