When using the RDBMS (ODBC) interface, you can take advantage of placeholders - see UserGuide - to pass different timestamps when running history recovery.
Typically, the interface performs data recovery during startup (offline mode), before it begins its normal data collection (online mode). In addition, you can run the interface in pure replication mode, specifying the time period for which you want to recover data (History Recovery Only mode). In pure replication mode, the interface scans the source for data from the specified time period, updates the target by executing the queries that you define, then exits.
When running in history recovery, placeholders will be replaced by the time passed by the history recovery. For example, if you are performing history recovery from 01-FEB-2018 to 05-FEB-2018, with a 1d step, it would pass 01-FEB-2018 for TS, then 02-FEB-2018, all the way to the 05-FEB-2018.
You can then use P1=TS in the tag configuration and pass the placeholder in the query: Get_Values(tagname, ?, end_time(optional))