Skip to content

Instantly share code, notes, and snippets.

@alokstha1
Created June 25, 2019 08:13
Show Gist options
  • Save alokstha1/5a36cb4f48fc36b7e03968ba066185f5 to your computer and use it in GitHub Desktop.
Save alokstha1/5a36cb4f48fc36b7e03968ba066185f5 to your computer and use it in GitHub Desktop.
SQL to get results from the last Month
<?php
global $wpdb;
$result = $wpdb->get_results("SELECT * FROM `$table` WHERE `user_id` = $user_id $extend AND MONTH(created) = MONTH(CURRENT_DATE())
AND YEAR(created) = YEAR(CURRENT_DATE()) order by id DESC" );
//created being a nave of a date column 2019-04-10 19:03:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment