Create a Formatted Date String
This routine illustrates how to create a formatted date string that includes the day of the week, month, day, and year (e.g., Friday April 14, 2006).
How It Works
The formatted date is computed with a combination of the @Today, @Weekday, @Year, @Month, and @Day functions. The returned values are subsequently used to create the formatted date string, which is stored in the theDate variable.
Implementation
To implement this solution, insert the following formula in an action button, column, or default value for a field. Optionally, replace @Today with a date or field. The @Prompt statement is used for illustrative purposes and can be removed or updated as desired. However, if removed, be sure the formula contains a main expression (i.e., Result) as the last statement in the formula.
theDate := @Today; theWeekday := @Select(@Weekday (theDate); "Sunday"; "Monday"; "Tuesday"; "Wednesday"; "Thursday"; "Friday"; "Saturday" ); theMonth := @Select(@Month(theDate); "January"; "February"; "March"; "April"; "May"; "June"; "July"; "August"; "September"; "October"; "November"; "December" ); theDay := @Text (@Day (@Today)); theYear := @Text (@Year (theDate)); result := "Today is " + theWeekday + " " + theMonth + " " + theDay + ", " + theYear; @Prompt([Ok];"Result"; result);
Figure 14.5 depicts the result when implemented in an action button.
Figure 14.5. Example of a formatted date string