On Thu, 28 Jun 2007, Alan Brown wrote: > I need to find tapes which are at. or close to expiry. > > Does anyone have a MYSQL snippet to do this?
I believe the following snippet will tell you all the Volumes due to expire in the next week, and the date and time they'll expire. It compares the LastWritten value + the VolRetention value to the current time. select VolumeName, FROM_UNIXTIME(UNIX_TIMESTAMP(LastWritten) + VolRetention) AS 'Expiration' from Media where DATEDIFF(FROM_UNIXTIME(UNIX_TIMESTAMP(LastWritten) + VolRetention), NOW()) <= 7; Obviously, change the last number to reflect your idea of 'close to expiry' - if you need all the tapes expiring tomorrow, change it to 1, etc. (And, of course, if I've misunderstood 'expiration', I apologize in advance) -- D ------------------------------------------------------------------------- This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ _______________________________________________ Bacula-users mailing list Bacula-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/bacula-users