11.07.2015 Views

Caché ObjectScript Reference - InterSystems Documentation

Caché ObjectScript Reference - InterSystems Documentation

Caché ObjectScript Reference - InterSystems Documentation

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>Caché</strong> <strong>ObjectScript</strong> Special VariablesThis special variable cannot be modified using the SET command. Attempting to do so resultsin a error.WRITE !,$ZUTIL(71,12345) // set $HOROLOG dateSET x=$HOROLOGSET y=$ZUTIL(188)SET z=$ZTIMESTAMPWRITE !,x," which is ",$ZDATETIME(x,1,1,9) // changed dateWRITE !,y," which is ",$ZDATETIME(y,1,1,9) // no date changeWRITE !,z," which is ",$ZDATETIME(z,1,1,9) // no date changeNote that $ZUTIL(71) changes the $HOROLOG value, but not the $ZUTIL(188) or$ZTIMESTAMP value.Local Time Variant Thresholds$HOROLOG calculates the number of seconds from midnight by consulting the systemclock. Therefore, if the system clock is automatically reset when crossing a local time variantthreshold, such as the beginning or end of Daylight Savings Time, the time value of$HOROLOG also shifts abruptly ahead or back by the appropriate number of seconds. Forthis reason, comparisons of two $HOROLOG time values may yield unanticipated resultsif the period between the two values includes a local time variant threshold.Dates Before 1840$HOROLOG cannot be directly used to represent dates outside of the range of years 1840through 9999. However, you can represent historic dates far beyond this range using the SQLJulian date feature. The SQL Julian date functions TO_DATE and TO_CHAR take an unsignedinteger and format it as a date, counting from 4711 BC (BCE). By using the $PIECE function,you can extract the date integer from $HOROLOG and use this as input to one of theseJulian date functions, as shown in the following example. Note that the $HOROLOG integerrepresenting the current date give a far different Julian date value. For example, a$HOROLOG date in the year 2004 gives a Julian date in the year 4548 BC.SET x=$PIECE($HOROLOG,",",1)&sql(SELECT TO_DATE(:x,'J') INTO :yFROM Sample.Person)WRITE !,"Julian date= ",yExamplesThe following example displays the current contents of $HOROLOG.WRITE $HOROLOGreturns a value formatted like this: 58923,49170434 <strong>Caché</strong> <strong>ObjectScript</strong> <strong>Reference</strong>

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!