ItSolutionStuff.com

MySQL Query to Get Current Year Data Example

By Hardik Savani • June 6, 2023
MySql

If you require to get all the records of current year using mysql query. for example you have one table "items" and columns are id, title, description, created_at and update_at, Now you want to get all records of this year. so you can fetch fields value using DATE_SUB and INTERVAL of mysql. In following example you can see how to select data of current year.

Example:

SELECT * FROM items WHERE created_at > DATE_SUB(NOW(), INTERVAL 1 YEAR);

I hope it can help you...

Tags: MySql
Hardik Savani

Hardik Savani

I'm a full-stack developer, entrepreneur, and founder of ItSolutionStuff.com. Passionate about PHP, Laravel, JavaScript, and helping developers grow.

📺 Subscribe on YouTube

We Are Recommending You

How to Export Mysql Database using Command Line in Ubuntu?

Read Now →

How to Get Filename from File Path in MySQL Query?

Read Now →

PHP Import Excel File into MySQL Database Tutorial

Read Now →

How to Get Last 2 Days Records from Table using MySQL Query?

Read Now →

How to Execute MySQL Query in Laravel?

Read Now →

MySQL Query to Get Current Month Data Example

Read Now →

How to Import CSV File using MySQL?

Read Now →

How to fetch this week records in MySql ?

Read Now →

How to Check Empty or Null Data using MySQL Query?

Read Now →

How to Copy One Table Data into Another Table using MySQL?

Read Now →

How to Get Difference Between Two Dates in Laravel?

Read Now →

How to count unique domains from email address field in MySQL ?

Read Now →

Which MySQL Datatype use for Store an IP Address?

Read Now →