Access functions: list with examples
The functions you need most in Access queries on one page: nulls, conditions, text, numbers, dates, totals queries, domain functions and criteria. Each comes with an example you can run online straight away.
In short: functions look the same in the query design grid and in SQL view, for example IIf(UnitPrice > 10, "high", "low"). Text goes in quotes, field names with spaces in square brackets, and dates between hash signs as month/day/year.
All examples run on the Shop practice database with the tables Customers, Products, Categories, Orders and OrderDetails. Copy a line into Access SQL online and run it without installing Access. We ran every example in Access 2024 and compared the result with ours. You can download the database itself as an .accdb file from the database examples.
Jump to: Nulls and conditions, Text, Numbers, Dates, Totals queries, Domain functions, Criteria
Cheat sheet as a PDF
The cheat sheet is free as a printable PDF. All you need is a free account, no subscription and no payment details.
Create a free account and download the PDF Already have an account? Log in
Nulls and conditions
| Function | Use | Example (SQL view) | Lesson |
|---|---|---|---|
Nz | replace Null with a substitute value | SELECT LastName, Nz(City, "unknown") AS Town FROM Customers | Calculated fields and IIf |
IIf | one of two values depending on a condition | SELECT ProductName, IIf(UnitsInStock < 10, "reorder", "ok") AS Status FROM Products | Calculated fields and IIf |
Switch | value of the first condition that is true | SELECT ProductName, Switch(UnitPrice < 5, "low", UnitPrice < 20, "medium", True, "high") AS PriceBand FROM Products | |
Choose | value by its position in a list | SELECT OrderID, Choose(Weekday(OrderDate, 2), "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun") AS WeekDay FROM Orders | |
IsNull | tests whether a value is Null | SELECT OrderID, IsNull(ShippedDate) AS NotShipped FROM Orders |
Text
| Function | Use | Example (SQL view) | Lesson |
|---|---|---|---|
Left | the first characters | SELECT LastName, Left(PostalCode, 2) AS Area FROM Customers | |
Right | the last characters | SELECT LastName, Right(LastName, 2) AS Ending FROM Customers | |
Mid | characters from a position | SELECT LastName, Mid(LastName, 2, 3) AS Middle FROM Customers | |
Len | number of characters | SELECT ProductName, Len(ProductName) AS Chars FROM Products | |
InStr | position where a text occurs (0 = not found) | SELECT ProductName, InStr(ProductName, " ") AS Space FROM Products | |
Trim | remove leading and trailing spaces | SELECT Trim(" " & LastName & " ") AS Name FROM Customers | |
UCase, LCase | to upper or lower case | SELECT UCase(LastName) AS Upper, LCase(City) AS Lower FROM Customers | |
Replace | replace text with other text | SELECT ProductName, Replace(ProductName, " ", "-") AS Slug FROM Products | |
StrConv | convert case, 3 = capitalise each word | SELECT StrConv(UCase(LastName), 3) AS Name FROM Customers | |
& | join texts, Null becomes empty text | SELECT FirstName & " " & LastName AS Name FROM Customers | Calculated fields and IIf |
Format | number or date as text in a given format | SELECT OrderID, Format(OrderDate, "yyyy-mm") AS YearMonth FROM Orders | Crosstab query |
Numbers
| Function | Use | Example (SQL view) | Lesson |
|---|---|---|---|
Round | round to places, exactly .5 goes to the even number | SELECT ProductName, Round(UnitPrice * 0.9, 2) AS SalePrice FROM Products | |
Int, Fix | integer part (Int rounds down, Fix truncates) | SELECT ProductName, Int(UnitPrice) AS Whole FROM Products | |
Abs | value without its sign | SELECT OrderID, Abs(OrderDate - ShippedDate) AS Days FROM Orders | |
Val | number at the start of a text | SELECT PostalCode, Val(PostalCode) AS Num FROM Customers | |
CCur, CDbl, CLng, CStr | convert to currency, double, long integer or text | SELECT ProductName, CLng(UnitPrice) AS Rounded, CStr(UnitsInStock) AS AsText FROM Products | |
\, Mod | integer division and remainder | SELECT ProductName, UnitsInStock \ 12 AS Boxes, UnitsInStock Mod 12 AS Leftover FROM Products | |
Sqr | square root | SELECT Sqr(Sum(Quantity)) AS Root FROM OrderDetails |
Dates
| Function | Use | Example (SQL view) | Lesson |
|---|---|---|---|
Date, Now | today's date, or with the time (fixed to 30 Nov 2026 in the exercises) | SELECT OrderID FROM Orders WHERE OrderDate >= Date() - 30 | Dates and empty fields |
Year, Month, Day | year, month or day of a date | SELECT OrderID, Year(OrderDate) AS OrderYear, Month(OrderDate) AS OrderMonth FROM Orders | Dates and empty fields |
Weekday | day of the week as a number, with 2 as second argument Monday is 1 | SELECT OrderID, Weekday(OrderDate, 2) AS WeekDay FROM Orders | |
MonthName | name of the month | SELECT OrderID, MonthName(Month(OrderDate)) AS MonthName FROM Orders | |
DateDiff | difference between two dates in days ("d"), months ("m") or years ("yyyy") | SELECT OrderID, DateDiff("d", OrderDate, ShippedDate) AS LeadTime FROM Orders | |
DateAdd | shift a date by days, months or years | SELECT OrderID, DateAdd("m", 1, OrderDate) AS Reminder FROM Orders | |
DatePart | part of a date, such as the quarter ("q") | SELECT OrderID, DatePart("q", OrderDate) AS Quarter FROM Orders | |
DateSerial | date from year, month and day | SELECT OrderID FROM Orders WHERE OrderDate >= DateSerial(2026, 3, 1) | |
#…# | date in SQL view, always month/day/year | SELECT OrderID FROM Orders WHERE OrderDate = #3/8/2026# | Dates and empty fields |
Totals queries
| Function | Use | Example (SQL view) | Lesson |
|---|---|---|---|
Sum | sum | SELECT OrderID, Sum(Quantity * SalePrice) AS OrderValue FROM OrderDetails GROUP BY OrderID | Totals query |
Count | number of values; Count(*) counts rows, Count(field) only non-Null values | SELECT Count(*) AS AllOrders, Count(ShippedDate) AS Shipped FROM Orders | Totals query |
Avg | average | SELECT CategoryID, Avg(UnitPrice) AS AvgPrice FROM Products GROUP BY CategoryID | Totals query |
Min, Max | smallest or largest value | SELECT CustomerID, Min(OrderDate) AS FirstOrder, Max(OrderDate) AS LastOrder FROM Orders GROUP BY CustomerID | Totals query |
First, Last | value of the first or last row in the group | SELECT CustomerID, First(PaymentMethod) AS FirstPayment FROM Orders GROUP BY CustomerID | |
StDev, Var | standard deviation or variance of a sample | SELECT StDev(UnitPrice) AS Spread FROM Products |
Domain functions
| Function | Use | Example (SQL view) | Lesson |
|---|---|---|---|
DLookup | look up one value in a table or query | SELECT OrderID, DLookup("LastName", "Customers", "CustomerID = " & CustomerID) AS Customer FROM Orders | Domain functions DLookup, DSum, DCount |
DCount | count records that meet a condition | SELECT LastName, DCount("*", "Orders", "CustomerID = " & CustomerID) AS OrderCount FROM Customers | Domain functions DLookup, DSum, DCount |
DSum | sum over records that meet a condition | SELECT ProductName, DSum("Quantity", "OrderDetails", "ProductID = " & ProductID) AS UnitsSold FROM Products | Domain functions DLookup, DSum, DCount |
DAvg, DMin, DMax | average, smallest or largest value with a condition | SELECT ProductName, UnitPrice - DAvg("UnitPrice", "Products") AS Difference FROM Products | Domain functions DLookup, DSum, DCount |
Criteria
| Function | Use | Example (SQL view) | Lesson |
|---|---|---|---|
Like | pattern with * (any characters) and ? (one character) | SELECT LastName FROM Customers WHERE LastName Like "W*" | Wildcards with Like |
Between … And | range including both ends | SELECT ProductName FROM Products WHERE UnitPrice Between 5 And 10 | Query criteria |
In | one of several values | SELECT LastName, City FROM Customers WHERE City In ("Bristol", "Boston") | AND and OR in criteria |
Is Null | field is empty | SELECT OrderID FROM Orders WHERE ShippedDate Is Null | Query criteria |
Not | reverse a condition | SELECT LastName FROM Customers WHERE Not Regular | Query criteria |
Rules that always apply
- Dates: In SQL view a date goes between hash signs and is always month/day/year:
#3/8/2026#is 8 March 2026, whatever your regional settings say. In the design grid Access reads a date in your system format and converts it. More in the lesson date criteria. - Interval codes: DateDiff, DateAdd and DatePart take
"d"(day),"ww"(week),"m"(month),"q"(quarter) and"yyyy"(year)."y"is day of the year, not year. - Null spreads: Any calculation with an empty field returns Null.
&treats Null as empty text,+does not. Replace Null first withNz, more in the lesson calculated fields. - Reserved words as column names: Access rejects
AS Text,AS Date,AS ValueorAS Orderwith "The SELECT statement includes a reserved word …". Choose another name or put it in square brackets:AS [Date]. - Quotes: Access SQL accepts both
"text"and'text'. Wildcards in Like are*and?, not%and_as in other SQL dialects. More in the lesson SQL view. - Today in the exercises:
Date()andNow()always return 30 Nov 2026 on this site so results stay the same. In Access it is the real current date.
How to learn the functions
A list is no substitute for practice. In the Access course you write these functions yourself, in the design grid and in SQL view, and the server checks your result with the visible data and with hidden data. That way you find out whether your query also works with other customers, prices and dates.