Who was president of the USA?
PHP, 936 bytes



for($a=explode('-',gzinflate(base64_decode('dVTRbtswDPwV/YANKXZq+zFJ1wRts3VZtgB7Y2Mm1ipLAO0089+PtNIuHbAnAzySd+RRNkVZ6XxSJUsMdES1g66x/tgHn5iiKnSms+Q+NF7Nami7xJTajLFtE1ro1D0eDkidZJe6itnQYqfWUNsYNsV1OHgKyNHJ9G/rryfr98M7wyT2mfma8KzuYf8SG2Wx0Rqot179AK/mJ0JB8qhpZ52z0KoVehrUCoguEhjP38i2g0OS2PRK1kOqnoJ7kXAk/wn7BrjJFgYXJH2qdaHLZM0UQLW6428bSCaZZmPFHYF/cSzsySLtR+B68PmJG3oQNTdR7eyZoGG1jzx8cCMw1bnJ3wdntVH+TdT03Q1dx62+pWrJZD0jRaTYnPoG6RBY2DzlwQeUPZbmin/GRUAHi66OUGXKZNFg1yMJOKO+OcmgZdzLksIrIwuHr+jAj0VRxhz9L2h50KsFV9n/ii4n9GbNev9gvcMhMZUWDXJIGGrepNqE0EldL1j10dBwlqVv4SCgiWS7EGoKZ8VJo4hqcrkCloVeLWURVPMtC5RpPtxkAe6VhS9CcLY+ogCRaIX0jNQzkQzA8ewfU2/TD/pyccoksoFB/NjSqRVvKz4GY6rk9myPTS9Vn2yHvgnnsSs7L+h4h3epekDvsZZd3GTGTEzyOPg6ePHw3fyKzZeajZWDrNVn+3sMFzlPVPKrJXB8jmy9BIvY37btoBb8TkbWMrJugpfUDcJxlFrGxpd3v0rVLuUr7RqGqjjFnNfPZlovf4OJ1ua64C2b47HRHIifqvryDC1w1EQtfwA=')));$d=$a[+$i++];)date(Ymd,strtotime($argn))&gt;$d?$m=$a[$i++]:die($m);echo'Donald Trump';


Try it online!



Tests: 
Try it online!

The code for tests is the same logic but a little bit different to replace the die(...) with return... so I can loop over tests.



I have created a string having start date of presidency minus 1 day in format of YYYYMMDD and name of president in it, separated by -. Example: 17890429-George Washington-17970303-John Adams-18010303-Thomas Jefferson-...

This string is compressed using gzdeflate and also the compressed output is converted to base-64 so all characters are printable ASCII and I can post them here or use them in TIO.

In the script, the string is split by - and looped over. For each loop iteration:


$d is set to current iteration value (which is the president's start date -1 day) and the loop variable ($i) is increased by one.
If input date is larger than $d, then $m is set to next iteration value (which is the president name for $d) and the loop variable ($i) is increased by one again. This allows the loop to get president names but jump over them in iterations.
If input date is not larger than $d, then that means the previous iteration was the correct president, so $m is printed using die function, this will stop the whole program after printing the name.


At the end, if the loop is finished (which means no die was called), the last president's name is printed, since we know non of previous presidents have got a match (so basically anything after January 19, 2017) prints last president's name, even if it is January 1, 3999.