Skip to content
Question

Q.Write SQL queries to perform the following : (I) Display the month (in numeric form) of the date '2026-01-01'. (II) Display only the year part from the date '2026-01-01'.

CBSECBSE Class XII Board 2026Subjective· 2mImportance★★★★★
🔒 Locked · start free trial →

You're viewing a preview — the full solution, concept, methods & PYQ mapping are locked.

Start your 14-day free trial to unlock the full solution →

SQL provides specific functions like MONTH() and YEAR() to extract individual components from a date value, simplifying data manipulation.

In the world of databases, dates and times are fundamental data types, but often, we don't need the entire date-time stamp. Instead, we might only be interested in a specific part of it—perhaps just the month for a sales report, or the year for an annual summary. This is where SQL's powerful Date Time Functions come into play. These functions allow us to manipulate, format, and extract specific components from date and time values, making our queries much more flexible and our data analysis more precise.

Let's look at how we can extract the month and year from a given date using standard SQL functions.

(I) Display the month (in numeric form) of the date '2026-01-01'.

To display only the month from a date, SQL offers dedicated functions. A common and straightforward function for this purpose is MONTH(). When you pass a date string or a date column to MONTH(), it returns the numeric representation of the month (1 for January, 2 for February, and so on).

Here is the SQL query to achieve this:

SELECT MONTH('2026-01-01');
Note

While MONTH() is widely supported in many SQL database systems like MySQL and SQL Server, a more ANSI SQL standard way to extract parts of a date is using the EXTRACT() function. For example, SELECT EXTRACT(MONTH FROM '2026-01-01'); would achieve the same result and is often preferred for portability across different database systems.

(II) Display only the year part from the date '2026-01-01'. …

Unlock everything free for 14 days

  • Full step-by-step solutions
  • Concept-first explanations
  • Methods, shortcuts & mistakes
  • PYQ mapping + timed mock tests

Full access for 14 days. No credit card required.