Get all results of 1 year ago and older datetime field [closed] - php

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 12 months ago.
Improve this question
I want to check if an membership of an user is created 1 year ago or longer.
I have this now:
SELECT * FROM users WHERE date >= NOW() - INTERVAL 1 YEAR
But i get results of 17-03-2021 in the list, when that is not an year ago.
I want to get all results from the Users when created account one year ago
or longer than.
How i can do that? I googled but i cant find an solution.
Thanks in advance.

SELECT * FROM users WHERE date < NOW() - INTERVAL 1 YEAR
Where date smaller then one year ago, you had greater then.

Related

foreach loop with if statements [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 8 days ago.
Improve this question
<?php
$income = array(19500, 22000, 85205, 110000, 26568, 12000, 37500, 50900, 28000, 32430);
$percentage = 0.09;
foreach($income as $integers)
{
echo ("$integers <br/>");
}
if ($integers < 26568);
{
echo "$integers = Pay back £0 per year";
}
?>
outcome below
19500
22000
85205
110000
26568
12000
37500
50900
28000
32430
32430 = Pay back £0 per year
If it is lower than 26568 then next to the number I want it to say "Pay back £0 per year" but if it's more than 26568 I need to calculate 9 percentage and add how much is paid back next to the number. Is this possible?
I tried the above and keep getting the same output, I need to be able to calculate the 9 percent and add this next to the number.

How to query data expiration time in mysql php [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 4 years ago.
Improve this question
In my Database I have products that i saved with the expiration timestamp in the format eg. 2018-22-08. Please how do I select all products that will expire in less than 4 days.
I have tried
SELECT * FROM table WHERE expiration_timestamp = DATE_ADD(CURDATE(), INTERVAL 4 DAY)
You should use less than operator
SELECT * FROM table WHERE expiration_timestamp < DATE_ADD(CURDATE(), INTERVAL 4 DAY)

php mysql ORDER BY not working ... tried looking at others, they aren't having the same issue [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 6 years ago.
Improve this question
please help ... i'm pretty knowledgeable when it comes to php mysql, but for some reason i can't figure this out.
i have this query:
$get_points = "SELECT user_id, accum_points FROM total_points ORDER BY accum_points DESC";
$run_points = mysqli_query($con, $get_points);
while($row_points = mysqli_fetch_array($run_points)) {
other stuff in here
}
and here's what is currently in the db
points_id | user_id | accum_points
_____________________________________
31 12 211.2
32 13 7.4
33 1 10.4
but it spits out it in the order of 7.4, 211.2, 10.4. i don't understand what is going on with this ... i've looked at a lot of the other questions asked about ORDER BY not working ... can anybody help?
thanks!
i made the mistake of making the column a varchar ... so that was stupid of me ... sorry about this guys

delete rows in mysql database if selected time has passed [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 8 years ago.
Improve this question
I want to delete rows from the database once a set amount of time has passed and the code I have isn't working and I am not sure where I have gone wrong. I plan to change the amount of time to 1 month but it is currently 1 minute for testing purposes.
require 'core/init.php';
$remOld = "DELETE * FROM `ratings` WHERE `ratedate` < NOW() - INTERVAL 1 MINUTE";
if ($remOld = $db->query($remOld)){
echo ('records removed');
}else{
echo ('didnt remove records');
}
Any pointers would be much appreciated.
Remove * from query and close open bracket in your query.
DELETE FROM `ratings` WHERE `ratedate` < (NOW() - INTERVAL 1 MINUTE)
try like this
$remOld = "DELETE FROM `ratings` WHERE `ratedate` < NOW() - INTERVAL '1 MINUTE'";
if ($remOld = $db->query($remOld)){
echo ('records removed');
}else{
echo ('didnt remove records');
}

Code for booking site [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 9 years ago.
Improve this question
I've a table with some records like this
date price
01/02/2000 20
02/02/2000 20
03/02/2000 20
the user will choose on my site the date of check-in and out. For example:
check-in: 01/02
check-out: 02/02
I' can i do a function that count the day from 01/02 to 02/02, and sum the price of the 2 days?
Thanks a lot
Pretty simple SQL to calculate the count and sum of the fields between your dates:
SELECT COUNT(*) AS count_dates, SUM(price) AS total_price
FROM your_table
WHERE date >= '01/02/2000'
AND date <= '02/02/2000'
Well, this is not enough infromation what you realy want to get. But my best gues:
SELECT SUM(Price), Count(*) as count_day
Where date>check-in and date<check-out

Categories