Answer the question
In order to leave comments, you need to log in
How to get only a list of dates by day if the records in the database contain a date field in the format 2017-07-20 09:00:47?
The wp_konkurs database contains records; they have a user_time field with a date and time in the format 2017-07-20 09:00:47
for one date there can be N records.
It is necessary to form a select in which only dates for the last 2 weeks will be displayed, for
example
, 2017-07 -01
2017-07-02
2017-07-N
now only the dates and times of the last 14 records are displayed, help me write a SQL query
<select class="form-control" id="sel1">
<?php
$userLists = $wpdb->get_results( 'SELECT user_time FROM wp_konkurs ORDER BY user_time DESC LIMIT 14 ');
foreach($userLists as $count):
echo "<option> $count->user_time </option>";
endforeach; ?>
</select>
Answer the question
In order to leave comments, you need to log in
SELECT DISTINCT DATE_FORMAT(user_time, '%Y-%m-%d') date
FROM wp_konkurs
ORDER BY date DESC
LIMIT 14
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question