0

I have two columns in my MySql database activeAt(timestamp) activeAtTime(time)

I want to fetch data that are less than activeAtTime(timestamp) and activeAt(time)

The problem I'm facing in my code is if activeAt is 25th may & activeAtTime is 5pm of an particular post and If the fetch the data with below code at 26th may 2pm it is not getting listed, but if i fetch at 26th may 5:30 pm the post is getting listed

(i used medoo, but you can suggest any query)

 "activeAt[<=]" => date("Y-m-d"),
 "activeAtTime[<=]" => date("H:i")

eg a post with activeAt and activeAtTime

If i make a fetch request at 25th may, 8 am this post is not getting listed

I'm trying to make a blogs that posts based on scheduled time and date i tried bootstrap datetime picker but it didn't work Is there any way i can combine activeAt and ActiveATtime So that the above logic works
What will be the most efficient way to do it?.

Sudhakar Behera
  • 91
  • 2
  • 10
  • _“What will be the most efficient way to do it?”_ - to not store date and time as two separate values to begin with. – CBroe Jun 05 '20 at 09:48
  • Otherwise, you will have to extend your condition accordingly - to select records that either have the date <= the current date, or the date == the current date AND the active time <= the current time. – CBroe Jun 05 '20 at 09:50
  • Please don't post pictures of text. It's daft, pointless, and irritating. – Strawberry Jun 05 '20 at 09:56
  • *I want to fetch data that are less than activeAtTime(timestamp) and activeAt(time)* Combine this two column values into one DATETIME or TIMESTAMP value using ADDTIME() or TIMESTAMP() function. – Akina Jun 05 '20 at 10:08
  • @CBroe, but from html i have only type="date" and type="time", I want help on joining them in single data where i can store it as an timestamp – Sudhakar Behera Jun 05 '20 at 10:55
  • Don’t just say “I want help”, explain what _exactly_ you need help with then. – CBroe Jun 05 '20 at 11:02
  • a way to join $_POST["activeDate"] and $_POST["activeTime"] from & respectively so that i store them in activeAt in mysql database as timestamp – Sudhakar Behera Jun 05 '20 at 11:23

0 Answers0