Professional > Interview scripting > Sample management > Sample management functions > UtcNow function
 
UtcNow function
One of the common tasks in Sample Management scripts for CATI projects is the calculation of appointment and other callback times. The calculations are all made relative to the current time. For example, when setting a callback time for a busy number, the calculation may simply add five or ten minutes to the current time. All times in Sample Management are stored in UTC format, and you can use the UtcNow function whenever you need to retrieve the current time in this format.
Syntax
UtcNow
Examples
This example shows a subroutine for setting an appointment time. When entering the appointment time, the interviewer can type “Now” for an immediate appointment or can enter the date and time that the respondent says. If the interviewer types “Now”, the subroutine uses UtcNow to find the time now.
Sub SetApptTime(SampleRec, strTimeField, _
      strNewStart, strNewInterval, iNewNumber)
  Select Case strNewStart
    Case "Now"
      SampleRec(strTimeField).Value = _
          DateAdd(strNewInterval, iNewNumber, UtcNow)
    Case Else
      SampleRec(strTimeField).Value = _
          DateAdd(strNewInterval, iNewNumber,_
          SampleRec(strNewStart).Value)
  End Select
End Sub
Another common use of UtcNow is in log messages where you want to record the time at which the message was written. For example:
LogStart = CreateLogStart + "GetSampleRec: "
LogMsg = LogStart + "Entered, current time (UTC) = " + CStr(UtcNow)
Log.LogThisEx 21, LogMsg, LOGLEVEL_INFO
See also
Sample management functions