MS Access: iif Function
In Access, the iif function returns one value if a specified condition evaluates to TRUE, or another value if it evaluates to FALSE.
The syntax for the iif function is:
iif ( condition, value_if_true, value_if_false )
condition is the value that you want to test.
value_if_true is the value that is returned if condition evaluates to TRUE.
value_if_false is the value that is return if condition evaluates to FALSE.
For Example:
iif ([Qty] > 10, "large", "small")
would return "large" if the value in the Qty field is greater than 10. Otherwise, it would return "small".
This is equivalent to the following IF statement in VBA code.
If [Qty] > 10 Then
result = "large"
Else
result = "small"
End If
Function: DateDiff()
Purpose: The DateDiff() function returns the difference between two dates.
Usage: DateDiff(interval, date1, date2)
Interval may be set to:
- yyyy for year
- q for quarter
- m for month
- y for day of year
- d for day
- w for weekday
- ww for week
- h for hour
- n for minute
- s for second
Returns: Number of intervals between date1 and date2.
Examples and Special Cases
DateDiff("yyyy", "6-Nov-2006", "7-Nov-2006") returns 0
DateDiff("yyyy", "31-Dec-2006", "1-Jan-2007") returns 1
DateDiff("d", "6-Nov-2006", "8-Nov-2006")
No comments:
Post a Comment