added date checkand temp date stuff;
swapped dates
added temp date stuff
bug fixes
fixed sql query