Related Information Examples & Tutorials

How To Use Date And Time Codes

Time

Time information may be used for tracking account activity, popping up a WIP for an operator to work, or alerting an operator to a timezone requirement on an account. Hours and minutes can be added or subtracted from the current time and used in calculations. Elapsed time can be determined by subtracting time fields.

For instance, you might want to remind an operator not to phone Hawaii before 11:00 AM when you are in New York. Or, you may want to know when a particular account was worked. In these cases, you can actually calculate these times, use them in control files or print them.

There is one format for Time:

@t Print the Time as HH:MM:SS
Example: 12:45:33

This code may be used with arithmetic operators arithmetic operators [+ or -] to calculate and print times in the past or future.

Top of page.

Using Time In Reports

The one format for time is displayed as hours:minutes:seconds. If you want to perform calculations on time, however, the time format is hoursminutesseconds without spaces or colons. Fill two spaces for each value, i.e. hours, minutes and seconds, and use the twenty-four hour clock.

Examples:

Time as displayed: 09:03:07
// This is three minutes and seven seconds after 9 AM.

The same time used in a calculation: 090307+020000
// This is 9:03:07 AM plus two hours - 11:03:07 AM is the result.

Current time is stored in @t. You may add or subtract from this to use in calculations, using time variables. To declare a Time variable, simply initialize your variable to a time field.

Examples:

@varTime = @de.wt
// This declares that the @varTime variable is going to hold a Time value.

@varFlag = 1 if (@varTime < @t+020000)
// This condition checks whether the Time stored in @varTime is less than two hours from now.

One use of this is timezones. For an example of setting the color of the phone field depending on time zones please refer to Help topic Timezone Alerts.

tip.gif Go to the Member Center and download a report snippet for formatting time using the twelve hour clock, AM and PM.

Go to the Member Center Add-Ons page.

Top of page.

Parsing Time

There is one time format @t. This gives the time as hh:mm:ss. You can put this into a string variable if you need parse it.

Use the following code to parse time values. Times earlier than 10 AM will have a leading zero. This is useful if you need a fixed length time format of 6 spaces for your time stamp.

@varTime = @t
@varStrTime* = @varTime
@varIntTime# = @varStrTime
@varZero* = 0
@varStrTime = @(varZero+varStrTime) if ( @varIntTime < 100000 )

Then you can parse the time as follows:

@varStrTime<2,0> is always two spaces for the hour
@varStrTime<2,2> is always two spaces for the minutes
@varStrTime<2,4> is always two spaces for the seconds

Top of page.

Date

There are numerous possibilities for displaying date information. You can display Today's Date, This Week, This Month, This Year. It is possible to add or subtract days, weeks, months or years from the current date for calculations in the past and future. Ranges of dates can be calculated and printed.

For instance, you might want to remind a debtor that an answer is required in 10 days or that a response was expected by the end of the previous month and was not forthcoming. Or you might want to remind someone that there will be added charges in 15 days. Or, you may want to include only information from account transactions that occur within a given time frame. In these cases, you can actually calculate these dates and print them.

Basic codes for printing date, week, month and year are displayed below. These codes are used with arithmetic operators to calculate and print dates in the past or future.

Top of page.

Basic Date Codes

The Basic Codes for Dates are as follows:

@d Print the Date as MM/DD/YYYY
Example: 06/22/2000
(Today)
@w Print the Date as MM/DD/YYYY
Example: 06/18/2000
(the first day of This Week)
@m Print the Date as MM/DD/YYYY
Example: 06/01/2000
(the first day of This Month)
@y Print the Date as MM/DD/YYYY
Example: 01/01/2000
(the first day of This Year)
@e Print the Date as Month DD, YYYY
Example: June 22, 2000
(Today)

All of these can have basic math applied. For example, @d+7 is one week from today.

You can also perform the math and put the result into a variable.

@varNextWeek = @d+7

Top of page.

Using Dates In Reports

There are many ways to control the printed format of dates. Please refer to How to Format Date Fields and Date Variables.

In addition, as mentioned above, there are many possibilities for calculating and printing dates in the past and future. Please see - How To Calculate Date Ranges in Reports and Letters
for more information.

Top of page.

Summary

Dates are also used in advanced report design. You will find references to them in How-to topics covering Lists and Loops, Conditionals, Variables and Math topics. Remember to review the list of pre-defined reports for examples. Also, Collect! Technical Services can build custom reports for complex use of date ranges and pulling information for reports.

Top of page.

See Also

- How to Format Date Fields and Date Variables
- How To Calculate Date Ranges in Reports and Letters
- Report Sample to view sample reports and letters
- Report Topics Index for a list of all report and letter topics

Top of page.

Was this page helpful? Do you have any comments on this document? Can we make it better? If so how may we improve this page.

Please click this link to send us your comments: helpinfo@collect.org