Question & Answer
Question
How can timestamp values available in the Tivoli Storage Manager server tables be used in select statements to filter data on dates and time?
Cause
Using timestamp values in a Tivoli Storage Manager select statement can be a challenge when trying to get data for a specific date or time period.
Answer
Proper casting and or standard SQL date/time functions can be used to help filter on date and time when there is a timestamp field in a table being processed.
To filter on a timestamp and display those items with a date/time of "today" the following syntax can be used:
- where date(current_timestamp)-date(<timestamp value from table>)=0
- select VOLUME_NAME, LAST_WRITE_DATE from VOLUMES where STGPOOL_NAME=TAPEPOOL' and date(current_timestamp)-date(LAST_WRITE_DATE)=0
When filtering on a timestamp to display only items for a specific day, the following syntax can be used:
- where date(<timestamp from table>)=date('<desired search date>')
- select VOLUME_NAME, LAST_WRITE_DATE from VOLUMES where STGPOOL_NAME='TAPEPOOL' and date(LAST_WRITE_DATE)=date('2014-04-22')
It is also possible to filter on a timestamp to obtain a listing that covers a specific date range by using the following syntax:
- where date(<timestamp from table>)>=date('<desired begin date>') and date(<timestamp from table>)<=date('<desired end date>')
- select VOLUME_NAME, LAST_WRITE_DATE from VOLUMES where STGPOOL_NAME='TAPEPOOL' and date(LAST_WRITE_DATE)>=date('2014-01-01') and date(LAST_WRITE_DATE)<= date('2014-01-31')
Product Synonym
TSM
Was this topic helpful?
Document Information
More support for:
Tivoli Storage Manager
Software version:
All Supported Versions
Document number:
244927
Modified date:
17 June 2018
UID
swg21670240