Add To Query Based Off Date Picker Or Drop Down List
I'm not familiar with Joomla's database library, so forgive me if some details below are suboptimal. But this is how it looks like you could start cleaning the script up.

// Query the dates.
$records = QueryDates();

// If we didn't get any dates...
if($records == null)
{
    echo "Please check the selection criteria and process again.";
}
else
{
    // Do something.
}



// Put your logic in a function that can be called wherever you need.
// You'll eventually want your PHP logic to be in a different file from
// your presentation markup.
function QueryDates()
{
    $bgin = $_POST['bgin'];
    $end  = $_POST['end'];

    if (isset($_POST['daterange'])) 
    {
        $datecriteria = $_POST['daterange'];
    }

    // Wrap our database interactions in a try-catch for safety.
    //
    // You might want to comment out the try-catch when first debugging.
    try
    {
        // Connect to the database.
        //
        // Is $option defined somewhere?
        $db = JDatabase::getInstance($option);

        // Get a new query object.
        $query = $db-&gt;getquery(true);

        // SELECT * FROM table_name ...
        $query-&gt;select('*');
        $query-&gt;from($db-&gt;quoteName('table_name'));

        // Get a quoted version of our datefield column.
        $datefield_name = $db-&gt;quoteName('datefield');

        if (isset($bgin) &amp;&amp; isset($end)) 
        {
            $query-&gt;where("$datefield_name &gt;= " . $db-&gt;quote($bgin), 'AND');
            $query-&gt;where("$datefield_name &lt;= " . $db-&gt;quote($end));
        }
        elseif (isset($datecriteria)) 
        {
            // Make sure the data is well-formed.
            if ($datecriteria != 10 
                &amp;&amp; $datecriteria != 20 
                &amp;&amp; $datecriteria != 30)
            {
                return null;
            }

            // Calculate our range.
            $min_date = DateAdd(day, $datecriteria * -1, getdate());

            $query-&gt;where("$datefield_name &gt;= " . $db-&gt;quote($min_date), 'AND');
            $query-&gt;where("$datefield_name &lt;= " . $db-&gt;quote(getdate()));
        }   
        else 
        {
            return null;
        }

        // Execute the query.
        $db-&gt;setQuery($query);
        $results = $db-&gt;loadObjectList();

        return $results;
    }
    catch (Exception $e)
    {
        // Could return something more useful, based on what 
        // is containe din $e.
        return null;
    }
}


You'll notice a few things here. Let's break them down:


I put your logic into a function. It's a good habit to get into, as
you start to learn more about PHP and web development. You'll start
to out-grow the mode of putting all your PHP code in the same file
as your HTML markup and will start to write functions you want to
call from multiple pages.
I changed your query from being a string to a series of function
calls. Joomla appears to utilize an abstraction library where you
build queries out of function calls against a query object. It also
appears to use quoteName for input sanitation.

That last part sounds iffy, to me. If Joomla has query parameters,
I'd recommend you use those, instead. But, as in the intro, I'm not
familiar with the Joomla db library so this is what their
documentation seems to suggest doing. 
https://docs.joomla.org/Selecting_data_using_JDatabase

In either case, don't simply pass a POST parameter into the query. You'll be 
opening up your entire database to anyone who knows basic SQL Injection 
(including the droves of SQL Injection bots that will find your site).
I have the new function return null whenever something goes wrong. This 
allows you to check for the bad output after the function call and handle it 
there, however you need to. Again, if you were to call this function from 
different pages, each might have its own way of dealing with the bad output.

The Joomla documentation doesn't say if loadObjectList() returns something
like null or false if the query fails. If it does return null, you might 
need to change all my "return null;"s to be something like "return false;", 
so you don't confuse the two outputs.
Finally, I set a try-catch block around your database interaction. This is 
good practice in production, as it will avoid nasty errors from hitting your 
users. But it may be troublesome while you're developing the code (as it 
will prevent you from seeing when something goes wrong). I'd recommend 
commenting out the try-catch until you do publish the site to your 
production environment.




As for speed, most of those 3 seconds for loading is likely network flight time (though, I assume you're running this locally) and the interaction with your database. There's not a lot you can do to speed up the traffic of sending the query and receiving the data, outside of environmental changes (eg. getting a faster hard drive on the server).

The one thing you can do is make sure your database schema is structured to facilitate speedy queries. For instance, if you're constantly querying against this "datefield", you might consider putting an index on it.

Depending on the data being returned, you can also tweak the cache. For instance, if users are frequently querying the same data, ensure that the cache is actually storing that data (rather than saying it's too big and dumping it or having the cache outright turned off).

If you expect a bunch of users to be using the page, you might also want to put stricter limits on the range of dates that can be queried. Having someone try to dump your entire database could cause slowdowns for other users.

But a lot of this is up to details you haven't given us.