Get database records count from today 8am to tomorrow 8am in mysql using php [on hold]











up vote
1
down vote

favorite
1












I am trying to get data count from today 8am to tomorrow 8am for inserting the every shopping order count.



I tried below code



$tomorrow=strtotime('+1 day', strtotime('8:00 AM'));
$today=strtotime('8:00 AM');


Mysql query



INSERT INTO tbl_order (user_id,sno,total,datetime)
VALUES('$userid',(SELECT count(user_id) from tbl_order o where o.datetime>=$today and o.datetime<$tomorrow)+1,'$total',time())


Since my variables are dynamic it won't work after end of the day. I need a method to check till 8 AM, It should take yesterday as $today variable and so on.



For eg: If i'm running on 2018-10-14



$today = 2018-10-14 8:00;
$tomorrow = 2018-10-15 8:00;


Till tomorrow 8AM i need the same values, after 8 AM it should



 $today = 2018-10-15 8:00; 
$tomorrow = 2018-10-16 8:00;









share|improve this question















put on hold as unclear what you're asking by Nick, Sadikhasan, EdChum, ADyson, Unheilig 19 hours ago


Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.















  • Try this ----> where (CONVERT(created_at, DATETIME) BETWEEN '2018-10-11 08:00:00' and '2018-11-12 08:00:00')
    – Anupam Bhatt
    19 hours ago












  • Thanks.it didn't work.
    – Rahumathulla
    19 hours ago












  • You can add a if condition right? codeshare.io/aVe9J6
    – Jestin Sebastian
    18 hours ago

















up vote
1
down vote

favorite
1












I am trying to get data count from today 8am to tomorrow 8am for inserting the every shopping order count.



I tried below code



$tomorrow=strtotime('+1 day', strtotime('8:00 AM'));
$today=strtotime('8:00 AM');


Mysql query



INSERT INTO tbl_order (user_id,sno,total,datetime)
VALUES('$userid',(SELECT count(user_id) from tbl_order o where o.datetime>=$today and o.datetime<$tomorrow)+1,'$total',time())


Since my variables are dynamic it won't work after end of the day. I need a method to check till 8 AM, It should take yesterday as $today variable and so on.



For eg: If i'm running on 2018-10-14



$today = 2018-10-14 8:00;
$tomorrow = 2018-10-15 8:00;


Till tomorrow 8AM i need the same values, after 8 AM it should



 $today = 2018-10-15 8:00; 
$tomorrow = 2018-10-16 8:00;









share|improve this question















put on hold as unclear what you're asking by Nick, Sadikhasan, EdChum, ADyson, Unheilig 19 hours ago


Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.















  • Try this ----> where (CONVERT(created_at, DATETIME) BETWEEN '2018-10-11 08:00:00' and '2018-11-12 08:00:00')
    – Anupam Bhatt
    19 hours ago












  • Thanks.it didn't work.
    – Rahumathulla
    19 hours ago












  • You can add a if condition right? codeshare.io/aVe9J6
    – Jestin Sebastian
    18 hours ago















up vote
1
down vote

favorite
1









up vote
1
down vote

favorite
1






1





I am trying to get data count from today 8am to tomorrow 8am for inserting the every shopping order count.



I tried below code



$tomorrow=strtotime('+1 day', strtotime('8:00 AM'));
$today=strtotime('8:00 AM');


Mysql query



INSERT INTO tbl_order (user_id,sno,total,datetime)
VALUES('$userid',(SELECT count(user_id) from tbl_order o where o.datetime>=$today and o.datetime<$tomorrow)+1,'$total',time())


Since my variables are dynamic it won't work after end of the day. I need a method to check till 8 AM, It should take yesterday as $today variable and so on.



For eg: If i'm running on 2018-10-14



$today = 2018-10-14 8:00;
$tomorrow = 2018-10-15 8:00;


Till tomorrow 8AM i need the same values, after 8 AM it should



 $today = 2018-10-15 8:00; 
$tomorrow = 2018-10-16 8:00;









share|improve this question















I am trying to get data count from today 8am to tomorrow 8am for inserting the every shopping order count.



I tried below code



$tomorrow=strtotime('+1 day', strtotime('8:00 AM'));
$today=strtotime('8:00 AM');


Mysql query



INSERT INTO tbl_order (user_id,sno,total,datetime)
VALUES('$userid',(SELECT count(user_id) from tbl_order o where o.datetime>=$today and o.datetime<$tomorrow)+1,'$total',time())


Since my variables are dynamic it won't work after end of the day. I need a method to check till 8 AM, It should take yesterday as $today variable and so on.



For eg: If i'm running on 2018-10-14



$today = 2018-10-14 8:00;
$tomorrow = 2018-10-15 8:00;


Till tomorrow 8AM i need the same values, after 8 AM it should



 $today = 2018-10-15 8:00; 
$tomorrow = 2018-10-16 8:00;






php mysql






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 18 hours ago

























asked 21 hours ago









Rahumathulla

62




62




put on hold as unclear what you're asking by Nick, Sadikhasan, EdChum, ADyson, Unheilig 19 hours ago


Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.






put on hold as unclear what you're asking by Nick, Sadikhasan, EdChum, ADyson, Unheilig 19 hours ago


Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.














  • Try this ----> where (CONVERT(created_at, DATETIME) BETWEEN '2018-10-11 08:00:00' and '2018-11-12 08:00:00')
    – Anupam Bhatt
    19 hours ago












  • Thanks.it didn't work.
    – Rahumathulla
    19 hours ago












  • You can add a if condition right? codeshare.io/aVe9J6
    – Jestin Sebastian
    18 hours ago




















  • Try this ----> where (CONVERT(created_at, DATETIME) BETWEEN '2018-10-11 08:00:00' and '2018-11-12 08:00:00')
    – Anupam Bhatt
    19 hours ago












  • Thanks.it didn't work.
    – Rahumathulla
    19 hours ago












  • You can add a if condition right? codeshare.io/aVe9J6
    – Jestin Sebastian
    18 hours ago


















Try this ----> where (CONVERT(created_at, DATETIME) BETWEEN '2018-10-11 08:00:00' and '2018-11-12 08:00:00')
– Anupam Bhatt
19 hours ago






Try this ----> where (CONVERT(created_at, DATETIME) BETWEEN '2018-10-11 08:00:00' and '2018-11-12 08:00:00')
– Anupam Bhatt
19 hours ago














Thanks.it didn't work.
– Rahumathulla
19 hours ago






Thanks.it didn't work.
– Rahumathulla
19 hours ago














You can add a if condition right? codeshare.io/aVe9J6
– Jestin Sebastian
18 hours ago






You can add a if condition right? codeshare.io/aVe9J6
– Jestin Sebastian
18 hours ago



















active

oldest

votes






















active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes

Popular posts from this blog

404 Error Contact Form 7 ajax form submitting

How to know if a Active Directory user can login interactively

TypeError: fit_transform() missing 1 required positional argument: 'X'