Title: Sql by date custom fields wordpress
Last modified: August 30, 2016

---

# Sql by date custom fields wordpress

 *  [kakashi20](https://wordpress.org/support/users/kakashi20/)
 * (@kakashi20)
 * [10 years, 5 months ago](https://wordpress.org/support/topic/sql-by-date-custom-fields-wordpress/)
 * I have this SQL query that extracts the year and month of ” post_date ” posts
 * `$query = "SELECT YEAR(post_date) as`year`, MONTH(post_date) as`month`
    FROM 
   $wpdb->posts WHERE `post_type` = ‘$t’ AND `post_status` = ‘publish’ GROUP BY `
   year`, `month` ORDER BY `year` DESC, `month` ASC”;`
 * but I wonder , how I can do the same query but instead of ” post_date ” would
   be a date field created by the custom fields plugin.
 * Thank you

The topic ‘Sql by date custom fields wordpress’ is closed to new replies.

## Tags

 * [custom fields](https://wordpress.org/support/topic-tag/custom-fields/)
 * [MySQL](https://wordpress.org/support/topic-tag/mysql/)
 * [sql](https://wordpress.org/support/topic-tag/sql/)

 * 0 replies
 * 1 participant
 * Last reply from: [kakashi20](https://wordpress.org/support/users/kakashi20/)
 * Last activity: [10 years, 5 months ago](https://wordpress.org/support/topic/sql-by-date-custom-fields-wordpress/)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
