Managed to resolve it. Date returning from SQL query had slashes in it. Changed that and it is ok now.
It is giving error 'Path Not Found' at MoveFile line. The code works fine if I don't use the SQL bit. Please help me.
Separate names with a comma.