Common nsr_getdate formats

When scripting NetWorker functions, or simply entering various NetWorker commands, there are many times when a date and time representation must be entered into the command.

The formatting of the date and time you must confirm to the nsr_getdate conventions. The nsr_getdate format is very versatile and allows you to enter a wide range of date and time constraints in your scripts and commands.

In this article we will take a look at some of the more common nsr_getdate date and time formats that you can use. The best way to learn these date/time formats is with examples, so here they come:

Entering Dates

mminfo -a -r "savetime(17),name" -q "savetime<02/01/2001"
mminfo -a -r "savetime(17),name" -q "savetime<feb 01 2001"

Entering Dates and Times:

mminfo -a -q "savetime >= 02/01/2001 13:10:00"
mminfo -a -q "savetime >= 02/01/2001 01:10:00 pm"
mminfo -a -q "savetime >= 02/01/2001 01:10:00 pm gmt"
mminfo -a -q "savetime >= 02/01/2001 01:10:00 pm pst"

Notes:

  • If you do not specify a meridian (am or pm) a 24 hour clock is assumed
  • If you do not specify a timezone (gmt, est,pst...etc) the current timezone is assumed

Relative time

Relative time specifications can be entered into NetWorker commands and scripts. When specifying a relative time, the time is relative to the current date and time.

mminfo -a -r "savetime(17),name" -q "savetime >= yesterday"
mminfo -a -r "savetime(17),name" -q "savetime >= 30 days ago"
mminfo -a -r "savetime(17),name" -q "savetime >= last week"
mminfo -a -r "savetime(17),name" -q "savetime >= last month"
mminfo -a -r "savetime(17),name" -q "savetime >= 2 months ago"
mminfo -a -r "savetime(17),name" -q "savetime >= 2 hours ago"
mminfo -a -r "savetime(17),name" -q "savetime >= 15 minutes ago"
mminfo -a -r "savetime(17),name" -q "savetime >= 9600 seconds ago"
mminfo -a -r "savetime(17),name" -q "savetime >= -24 hours"

Final Thoughts

  • The nsr_getdate formats are very flexible. I did not cover all of the options available by any means, but I did try to illustrate the most common date and time formats.
  • Be especially careful when using relative date and time specifications. You may not always get the results you think you should. For example, if today is Thursday and you specify "next friday" this will be interpreted as the Friday of the next week, not tomorrow.
  • Careful consideration should be used before implementing scripts using the nsr_getdate formats.