Time stamps are really integer fields that store their data as seconds.
Thus, hours * 3600 seconds/hour can be subtracted when hours are selected.
Similar expressions can be used to subtract the equivalent seconds for days and weeks. And this can be done with a case statement that uses the specified units to apply the correct conversion.
Months and Years are more a problem because each month and each year is not the same length (don't forget leap years).
In those cases, you may want to use a different approach:
Here's an example for subtracting months:
Let ( [ TS = YourTimeStampField ; m = Month ( TS ) - YourNumberField ] ;
TimeStamp ( Date ( m ; Day ( TS ) ; Year ( TS ) ) ; Getastime ( TS ) )
A similar expression can subtract years.