Attachmate Worldwide  |   Contact Us  |   NetIQ.com
Home » Support » Solution Library

Technical Notes

Verastream Scripting Language Date Conversion Examples
Technical Note 10201
Last Reviewed 10-Aug-2007
Applies To
Component Developer version 8.0 or higher
Process Integrator version 8.0 or higher
Summary

This technical note presents two sample Verastream Scripting Language scripts that are used to manipulate date information. The first script determines the day of the year (1-365) for any date entered. The second script determines what day of the week any given date falls on.

Determine the Day of the Year for Any Date Entered

This script takes a date as input and outputs the day of the year on which the date falls.

DIALOG D1  ATCOL=100pixels ATLINE=100pixels COLS=398pixels \
 LINES=178pixels TITLE=Julian FONT=AP_DIALOG FLAT GRIDX=5pixels \
GRIDY=5pixels
{
  EDIT D1E1  X=55pixels Y=50pixels WIDTH=290pixels HEIGHT=free \
FIELD=mydate FONT=AP_EDIT BACKCOLOR=AP_EDIT_BG
  BUTTON D1B1  X=55pixels Y=110pixels WIDTH=295pixels \
 HEIGHT=25pixels TEXT=Calculate FONT=AP_BUTTON DEFAULT
  EDIT D1E2  X=55pixels Y=75pixels WIDTH=290pixels FIELD=julian \
 FONT=AP_EDIT BACKCOLOR=AP_EDIT_BG READONLY
  STRING D1S1  X=55pixels Y=30pixels WIDTH=105pixels \
TEXT=YYYY-MM-DD: FONT=AP_STRING
}

FUNCTION START START
{
  NEWDBG STATUS
  INIT BASE
  WAIT D1
}

FUNCTION PUSHED D1B1
{
  GET D1E1
  SET julian mydate-date(year(mydate),1,1)+1
  PUT D1E2
}

FIELD mydate date(10) FMT=YYYY-MM-DD
FIELD julian int(3)

Determine the Day of the Week for any Date Entered

This script uses the easter function, provided by the Verastream Integration Broker's Universal Integration Engine, to determine what day of the week any given date falls on. The script relies upon the fact that Easter always falls on a Sunday. It takes the date you input and subtracts the date on which Easter was observed in the prior year (this assures a positive integer). The script then calculates the modulo 7 of this figure and returns an integer from 0 to 6, where:

0 = Sunday

1 = Monday

2 = Tuesday

3 = Wednesday

4 = Thursday

5 = Friday

6 = Saturday

FUNCTION START START
{
LOCAL FIELD mydate date(10) FMT=YYYY/MM/DD

SET mydate date(2001,3,12)
FERROR BASE (mydate-easter(year(mydate)-1))%7
}

The following script uses the expression function format to determine what day of the week any given date falls on. Unlike the prior script, which returns a numeric value, this script returns the actual name of the day:

FUNCTION START START
{
LOCAL FIELD mydate date(10) FMT=YYYY/MM/DD

SET mydate date(2001,3,12)
FERROR BASE strip(format(mydate,'WWWWWWWWWWWW'))
}

Related Technical Notes
10999 Verastream Integration Broker Technical Notes

Did this technical note answer your question?

Yes    No    Somewhat     Not sure yet

Additional comments about this tech note:

Need further help? For technical support, please contact Support.