AllTools.Solutions
Salesforce Tools

SOQL Date/DateTime Literal Formatter

Convert a date or datetime into exact SOQL literal syntax — DST-aware, ready to paste into a query.

Timezone

Pick a date & time (or paste one) to see the SOQL literals.
SOQL relative date literal reference

These are used directly in SOQL, unquoted — there's nothing to convert. This is a reference, not a converter.

Day

  • TODAY, YESTERDAY, TOMORROW
  • LAST_N_DAYS:n / NEXT_N_DAYS:n
  • N_DAYS_AGO:n
  • LAST_90_DAYS / NEXT_90_DAYS

Week

  • LAST_WEEK, THIS_WEEK, NEXT_WEEK
  • LAST_N_WEEKS:n / NEXT_N_WEEKS:n

Month

  • LAST_MONTH, THIS_MONTH, NEXT_MONTH
  • LAST_N_MONTHS:n / NEXT_N_MONTHS:n

Quarter

  • LAST_QUARTER, THIS_QUARTER, NEXT_QUARTER
  • LAST_N_QUARTERS:n / NEXT_N_QUARTERS:n

Year

  • LAST_YEAR, THIS_YEAR, NEXT_YEAR
  • LAST_N_YEARS:n / NEXT_N_YEARS:n

Fiscal

  • THIS_FISCAL_QUARTER, LAST_FISCAL_QUARTER, NEXT_FISCAL_QUARTER
  • THIS_FISCAL_YEAR, LAST_FISCAL_YEAR, NEXT_FISCAL_YEAR

Requires your org's fiscal year config — this tool doesn't attempt to resolve fiscal boundaries.

Why SOQL dates trip up people who already know SQL

If you're coming from standard SQL, the instinct is to wrap dates in quotes — WHERE CloseDate = '2026-08-13'. In SOQL, that's wrong. Date literals and date values in SOQL are written without quotes: WHERE CloseDate = 2026-08-13. Quote it like a string and the query either fails or silently doesn't match what you expect, which makes it one of the more common gotchas for developers moving from traditional SQL into Salesforce.

Date literals are the other half of the story. SOQL supports relative keywords like THIS_MONTH, LAST_N_DAYS:7, and NEXT_N_YEARS:2 that resolve dynamically at query time — no manual date math required, and no need to hardcode a value that goes stale tomorrow. LAST_N_DAYS:7, for example, includes today plus the seven days before it, which surprises people expecting it to mean strictly “the previous 7 days, not including today.”

This tool handles the conversion between a normal date and the exact format SOQL expects, so you're not hand-editing query strings and re-testing every time the format trips you up.

Enjoyed this? Share it with a friend