This executes in the current database. Be advised that the query selects the MIN and MAX datetime values for every table / column in the database, so it will probably run for a while in any database over a few GB in size. A 4 GB database with 86 datetime columns took 4 seconds on my SQL 2012 instance, and a 250 GB database with 1039 datetime columns took a little over 17 minutes. Ymmv (your mileage may vary). It depends on the number of rows in the tables, how many datetime columns in each table, and if there are any indexes that could help..... This is basically a "brute force" query, so prepare to give it time. Execute it on a non-production copy of your database if at all possible.
This comes in handy when evaluating previously unfamiliar databases for the first time, like in a new job or contract.