Examples: Performing time-date operations
- (@Created) This agent example writes "Archive" to the Status field
if the current document was created before 1995, and writes "Current®" otherwise.
SELECT @All; FIELD Status := @If(@Created < [01/01/95 12:00:00 AM]; "Archive"; "Current");
- (@Modified, @Date, @Today, @Yesterday) This agent example writes
"Today," "Yesterday," or "Old" to the ViewStatus field, depending
on the date that the current document was last modified.
FIELD ViewStatus := @If(@Date(@Modified) = @Today; "Today"; @Date(@Modified) = @Yesterday; "Yesterday"; "Old"); SELECT @All
- (@Modified, @Date, @Weekday, @Today, @Adjust, @Yesterday) This
agent example modifies the preceding example to exclude weekends in
assigning "Yesterday." If today is Monday, y is set to today's date
minus 3 days; otherwise y is set to yesterday's date. Then y instead
of @Yesterday is tested against the @Modified date.
d := @Date(@Modified); y := @If(@Weekday(@Today) = 2; @Adjust(@Today; 0; 0; -3; 0; 0; 0); @Yesterday); FIELD ViewStatus := @If(d = @Today; "Today"; d = y; "Yesterday"; "Old"); SELECT @All
- (@Now, @Month, @Year, @Day) This example of a computed text field
displays today's date in letterhead form. For example, 6/30/95 displays
as "June 30, 1995."
months := "January" : "February" : "March" : "April" : "May" : "June" : "July" : "August" : "September" : "October" : "November" : "December"; month := @Subset(@Subset(months; @Month(@Now)); -1); year := @Year(@Now); day := @Day (@Now); month + " " + @Text(day) + ", " + @Text(year)
- (@Adjust, @Weekday, @Created) This example of a computed time
field displays a date two days from the creation date for the document.
The calculation eliminates the weekend by adding 4 days if the creation
date is a Friday.
increment := @If(@Weekday(@Created) = 6; 4; 2); @Date(@Adjust(@Created; 0; 0; increment; 0; 0; 0))
- (@BusinessDays) This agent displays the number of days in 2001
excluding Saturdays, Sundays, and 10 holidays.
@Prompt([Ok]; @Text( @BusinessDays([01/01/2001]; [12/31/2001]; 1 : 7; [01/01/2001] : [01/15/2001] : [02/16/2001] : [05/28/2001] : [07/04/2001] : [09/03/2001] : [10/08/2001] : [11/22/2001] : [11/23/2001] : [12/25/2001]) ); "Business days in 2001")