In standard SQL, which query correctly displays the current date returned by the database using the CURRENT_DATE function?

Difficulty: Medium

Correct Answer: SELECT CURRENT_DATE;

Explanation:


Introduction / Context:
Most relational databases provide built in functions to return the current date and sometimes the current date and time. Knowing the standard SQL way to request the current date is useful for writing portable queries that run on different database systems. This question focuses on the CURRENT_DATE function defined in the SQL standard and tests whether you can identify the correct syntax to display the current date.


Given Data / Assumptions:

  • The database supports standard SQL syntax.
  • The goal is to display the current date as returned by the server.
  • CURRENT_DATE is used as a function or special value that returns today's date.


Concept / Approach:
In standard SQL, CURRENT_DATE is an ANSI SQL function like CURRENT_TIME and CURRENT_TIMESTAMP. It can be selected without a FROM clause in many systems or with a dummy table in some implementations. The simplest form in many databases is SELECT CURRENT_DATE;. Other options in the list, such as SYSDATE FROM dual, are specific to particular platforms like Oracle and are not the standard portable answer requested in the question. Therefore, the correct choice is the query that uses CURRENT_DATE directly.


Step-by-Step Solution:
Step 1: Recall that the SQL standard provides CURRENT_DATE to fetch today's date.Step 2: Identify the option that uses this name correctly in a SELECT statement.Step 3: Option A is SELECT CURRENT_DATE; which is the canonical form in many SQL engines and matches the standard.Step 4: Option B uses SYSDATE FROM dual, which is Oracle specific. Option C uses NOW without parentheses and a dummy table, which is not standard. Option D uses DATE() against a table, which does not necessarily return the current date.Step 5: Choose option A as the correct standard SQL query.


Verification / Alternative check:
Documentation for PostgreSQL, MySQL and other systems shows examples where CURRENT_DATE can be used directly in a SELECT statement. In PostgreSQL you can run SELECT CURRENT_DATE; and in MySQL you can use SELECT CURRENT_DATE; or SELECT CURDATE();. Although many systems also support proprietary functions, CURRENT_DATE is the most portable across compliant databases, which is why it is highlighted in standard focused exam questions.


Why Other Options Are Wrong:
Option B is valid in Oracle where dual is a special dummy table and SYSDATE returns the system date and time, but it is not standard and fails on databases that do not have dual. Option C uses NOW incorrectly and is incomplete or non standard without parentheses, and NOW is not part of the core SQL standard. Option D misuses DATE() on a specific table and would depend on the column being used, so it does not represent a general way to get the current date.


Common Pitfalls:
Many students memorise platform specific functions such as GETDATE(), SYSDATE or NOW() and then forget which one is portable. In certification exams that emphasise generic SQL, questions often prefer the standard CURRENT_DATE syntax. To reduce confusion, remember that CURRENT_DATE, CURRENT_TIME and CURRENT_TIMESTAMP are part of the SQL standard and are safe answers when cross platform behaviour is discussed.


Final Answer:
SELECT CURRENT_DATE;

Discussion & Comments

No comments yet. Be the first to comment!
Join Discussion