SQL & Databases·Data in practice

Text and dates

Clean text and work with dates without guessing the dialect.

Beginner 12 min read Lesson 13 of 480 Challenge included
What you will be able to do
  • Transform text with SQL functions
  • Extract parts of a date
  • Spot dialect differences

Text and date functions differ between databases. Learn the concepts, then check the exact function names for your engine.

text-dates.sqlSQL
SELECT UPPER(substr(title, 1, 3)) AS code,
       title,
       length(title) AS chars,
       replace(course_slug, '-', '_') AS key
FROM lessons
WHERE title LIKE '%form%';

SELECT date('now') AS today,
       strftime('%Y-%m', 'now') AS month,
       julianday('2026-10-27') - julianday('2026-10-01') AS days;
TaskSQLitePostgreSQL
Lengthlength(text)length(text)
Substringsubstr(text, 1, 3)substring(text from 1 for 3)
Uppercaseupper(text)upper(text)
Todaydate('now')current_date
Extract yearstrftime('%Y', date)extract(year from date)
Your turn

Uppercase titles with length

Easy

Return each lesson title in uppercase and its character count, longest first.

SQL · starter
SELECT
FROM lessons
Check your understanding before moving on.
Knowledge checkQuestion 1

In SQLite, which function extracts the year from a date?

Select an answer to continue
Study tools

Make it yours.

Keep a private note for this lesson, then turn the key ideas into flashcards you can revisit.

Sign in to save notes and flashcards.Both are private to your account and stay with your progress.
Sign in
Finished reading?

Lock in what you just learned.

Mark this lesson complete to save your place and move one step closer to the certificate.

Next: Indexes and query plans
Lesson 13 of 480 · 0% of course