What are the advantages of restructuring a table to store day, month, and year separately for date-related queries in PHP?

When dealing with date-related queries in PHP, storing the day, month, and year separately in a table can make it easier to perform date calculations and comparisons. This allows for more efficient querying and sorting based on specific date components. Additionally, it can simplify date formatting and manipulation in PHP code.

// Example of restructuring a table to store day, month, and year separately for date-related queries in PHP

// Original table structure
// date_column (DATE)

// New table structure
// day_column (INT)
// month_column (INT)
// year_column (INT)

// Retrieving date components from the original date column
$date = "2022-10-15";
$day = date('d', strtotime($date));
$month = date('m', strtotime($date));
$year = date('Y', strtotime($date));

// Inserting date components into the new table structure
$query = "INSERT INTO date_table (day_column, month_column, year_column) VALUES ('$day', '$month', '$year')";
mysqli_query($conn, $query);