SELECT 'V' as Ind, Voucher_No, Voucher_Prefix, 'SALESVOUCHER' as VoucherType, Voucher_Date as Date, cast(Voucher_No as unsigned) as Voucher, (SELECT Ledger_Name from $master_db.Ledger_Master where Ledger_ID=stable.Ledger_ID) as Ledger,Total as 'Total Amount' From $trans_db.Sales_Invoice_Main stable WHERE  ( str_to_Date(concat(stable.Voucher_Date, substr(`TimeStamp`, 11,19)) ,'%Y-%m-%d %H:%i:%s')>= str_to_date('$fromDateTime','%Y-%m-%d %H:%i:%s') and str_to_Date(concat(stable.Voucher_Date, substr(`TimeStamp`, 11,19)) ,'%Y-%m-%d %H:%i:%s') <= str_to_date('$toDateTime','%Y-%m-%d %H:%i:%s')) order BY cast(Voucher_No as unsigned) desc