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.

You can obtain the same current date and time information by invoking a system method, asfollows:WRITE $SYSTEM.SYS.Horolog()Refer to the “Class %SYSTEM.SYS” section of the <strong>Caché</strong> Class <strong>Reference</strong> for further details.Separating Date and TimeTo get just the date portion or just the time portion of $HOROLOG, you can use the $PIECEfunction, specifying the comma as the delimiter character:SET dateint=$PIECE($HOROLOG,",",1)SET timeint=$PIECE($HOROLOG,",",2)WRITE !,"Date and time: ",$HOROLOGWRITE !,"Date only: ",dateintWRITE !,"Time only: ",timeintTo get just the date portion of a $HOROLOG value, you can also use the following programmingtrick:SET dateint=+$HOROLOGWRITE !,"Date and time: ",$HOROLOGWRITE !,"Date only: ",dateintThe plus sign (+) causes <strong>Caché</strong> to parse the $HOROLOG string as a number. When <strong>Caché</strong>encounters a non-numeric character (the comma) it truncates the rest of the string and returnsthe numeric portion. This is the date integer portion of the string.Date and Time ConversionsYou can use the $ZDATE function to convert the date portion of $HOROLOG into external,user-readable form. You can use the $ZTIME function to convert the time portion of$HOROLOG into external user-readable form. You can use the $ZDATETIME functionto convert both the date and time. When using $HOROLOG, setting the precision for timevalues in these functions always returns zeros as fractional seconds.You can use the $ZDATEH function to convert a user-readable date into the date portion of$HOROLOG. You can use the $ZTIMEH function to convert a user-readable time into thetime portion of $HOROLOG. You can use the $ZDATETIMEH function to convert boththe date and time to a $HOROLOG value.Setting the Date$HOROLOGYou can use the $ZUTIL(71) function to set $HOROLOG to a user-specified date for thecurrent process.<strong>Caché</strong> <strong>ObjectScript</strong> <strong>Reference</strong> 433

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

Saved successfully!

Ooh no, something went wrong!