0
0
SQLquery~10 mins

CURRENT_DATE and CURRENT_TIMESTAMP in SQL - Step-by-Step Execution

Choose your learning style9 modes available
Concept Flow - CURRENT_DATE and CURRENT_TIMESTAMP
Start Query
Evaluate CURRENT_DATE
Return current date only
Evaluate CURRENT_TIMESTAMP
Return current date and time
Display results
End Query
The query first gets the current date, then the current date and time, and finally shows both results.
Execution Sample
SQL
SELECT CURRENT_DATE AS today, CURRENT_TIMESTAMP AS now;
This query returns the current date and the current date with time.
Execution Table
StepActionEvaluationResult
1Start query executionN/AQuery begins
2Evaluate CURRENT_DATEGets current date only2024-06-15
3Evaluate CURRENT_TIMESTAMPGets current date and time2024-06-15 14:23:45
4Return resultsShow both values in outputtoday=2024-06-15, now=2024-06-15 14:23:45
5End queryAll values returnedQuery complete
💡 Query ends after returning current date and timestamp values
Variable Tracker
VariableStartAfter EvaluationFinal
todayNULL2024-06-152024-06-15
nowNULL2024-06-15 14:23:452024-06-15 14:23:45
Key Moments - 2 Insights
Why does CURRENT_DATE return only the date without time?
CURRENT_DATE is designed to return only the date part, as shown in execution_table step 2, so the time is not included.
Why does CURRENT_TIMESTAMP include both date and time?
CURRENT_TIMESTAMP returns the full date and time, as seen in execution_table step 3, because it captures the exact moment the query runs.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution_table, what value does 'today' have after evaluation?
A2024-06-15
B2024-06-15 14:23:45
CNULL
D2024-01-01
💡 Hint
Check the 'today' variable value in variable_tracker after evaluation
At which step does the query get the current date and time?
AStep 2
BStep 3
CStep 4
DStep 5
💡 Hint
Look at execution_table step descriptions for CURRENT_TIMESTAMP evaluation
If you only want the date without time, which function should you use?
ACURRENT_TIMESTAMP
BNOW()
CCURRENT_DATE
DGETDATE()
💡 Hint
Refer to key_moments about which function returns date only
Concept Snapshot
CURRENT_DATE returns the current date only (YYYY-MM-DD).
CURRENT_TIMESTAMP returns current date and time (YYYY-MM-DD HH:MM:SS).
Use CURRENT_DATE when time is not needed.
Use CURRENT_TIMESTAMP to get exact current time.
Both are evaluated at query run time.
Full Transcript
This visual execution trace shows how SQL functions CURRENT_DATE and CURRENT_TIMESTAMP work. The query starts and first evaluates CURRENT_DATE, which returns only the date part like 2024-06-15. Then it evaluates CURRENT_TIMESTAMP, which returns the full date and time like 2024-06-15 14:23:45. Both values are returned as query output. The variable tracker shows how 'today' and 'now' variables get their values step by step. Key moments clarify that CURRENT_DATE excludes time, while CURRENT_TIMESTAMP includes it. The quiz questions help reinforce understanding by asking about values at specific steps and correct function usage. This helps beginners see exactly how these functions behave during query execution.