SELECT 'V' , Voucher_No, Voucher_Prefix, 'PURCHASEORDER',  Voucher_Date as 'Voucher Date', CAST(Voucher_No as UNSIGNED) as 'Voucher No', (SELECT Ledger_Name FROM $master_db.Ledger_Master WHERE Ledger_ID= sim.Ledger_ID) Ledger, Total FROM $trans_db.Purchase_Order_Main sim WHERE str_to_date(concat(Voucher_Date,' ',CAST(`TimeStamp` AS TIME)),'%Y-%m-%d %H:%i:%s') >= str_to_date('$fromDateTime','%Y-%m-%d %H:%i:%s') AND str_to_date(concat(Voucher_Date,' ',CAST(`TimeStamp` AS TIME)),'%Y-%m-%d %H:%i:%s') <= str_to_date('$toDateTime','%Y-%m-%d %H:%i:%s')