Accessing Time Data
Developing TACL Programs
107365 Tandem Computers Incorporated
2–23
Converting Timestamps Into Different Formats
The macro in Figure 2-10,
getdates
, converts the current date from a three-word
timestamp to SQL format (yyyy-mm-dd), for use by report generators or other
programs. This type of macro could be used to generate SQL reports.
Figure 3-9 in Section 3, “Developing TACL Routines,” contains a modification of this
example that shows how a nested routine can return dates as results.
Figure 2-10. Converting Timestamps
?SECTION getdates MACRO
#FRAME
== Save the current setting of #OUTFORMAT,
== so that it can be restored later:
#PUSH #OUTFORMAT #INFORMAT
[#PUSH
date == starting date (30 days ago)
yyyy == year
mm == month
dd == day
]
#SET #OUTFORMAT PRETTY
== Get the date and convert to yyyy mm dd calendar format:
#SETMANY yyyy mm dd, [#CONTIME [#TIMESTAMP]]
== Store as yyyy-mm-dd format (SQL date format):
#SET date [yyyy]-[mm]-[dd]
== Display the results to the user
#OUTPUT The reports will use a date of [date]
{ place report-generation code here}
#UNFRAME