I would suggest not to modify the core files, because the update might overwrite it. Usually I use the Wordpress Header and Footer plugin. After you install it, Activate it, and you can place the scripts in the header or footer. The plugin can be accessed from the Settings menu. Will the above script going to work is another story because I'm not sure how your application being structure. Look like it will work if there a datepicker with the id "#datepicker" on the page.
Head, Footer and Post Injections — WordPress Plugins[
^]