iwantcoding.com
🔥 Daily 👥 Rooms 🏆 Top Log in Sign up

MS Access Functions

MS Access SQL is its own dialect — it sits closest to old-school VBA / Excel-style formulas. You'll meet it in small business apps and legacy reporting.

String

FunctionDoes
Len(s)Length.
UCase(s) / LCase(s)Case.
Left(s, n) / Right(s, n) / Mid(s, start, n)Substring.
InStr(s, find)Find position.
Replace(s, find, with)Replace.
Trim, LTrim, RTrimWhitespace.
Space(n)N spaces.

Numeric

Abs, Int, Round(x, n), Sgn, Mod, Rnd(), Int, Fix.

Date / time

FunctionReturns
Now()Current datetime.
Date() / Time()Today / current time.
DateAdd("d", 7, x)Add 7 days.
DateDiff("d", a, b)Difference in days.
DatePart("yyyy", x)Extract a part.
Format(x, "yyyy-mm-dd")Format to string.

NULL / conditional

Nz(x, fallback), IsNull(x), IIf(cond, t, f), Switch(c1, v1, c2, v2, …), Choose(idx, v1, v2, …).

Aggregate

Count, Sum, Avg, Min, Max, First, Last, DCount, DLookup (domain aggregates that take a SQL-like string).

Type conversion

CStr, CInt, CLng, CDbl, CDate, CBool — VBA conversion functions; valid in Access SQL too.

Tip: Access SQL also supports % and _ wildcards via ADO/OLEDB, but the Access UI shows * and ?. Same query, two grammars.

Example

Example
SELECT Now(), Date(),
       UCase('hi'), Left('hello', 3),
       Nz(phone, 'n/a')
FROM customers;
Try it Yourself »

Exercise

MS Access NULL replacement function.

(phone, 'n/a')

Test yourself

Q1. Access string length is…
Q2. Access NULL fallback is…
Q3. Inline IF in Access SQL is…

Discussion

Loading…