Welcome Guest, Not a member yet? Register   Sign In
Convert my sql query to codeigniter syntax
#1
Lightbulb 

I have a query which is:

SELECT COALESCE(sum(`lead_att`.`cost`), 0) as sale
FROM `lead_att`
JOIN `leads` ON `lead_att`.`lead_id` = `leads`.`lead_id`
WHERE (
    `leads`.`test_mode` = FALSE
    AND `lead_att`.`status` NOT IN (8, 9)
    AND str_to_date(date_format(`lead_att`.`created_at`, '%Y-%m-%d %H:%i'), '%Y-%m-%d %H:%i') BETWEEN str_to_date(date_format(convert_tz( DATE_FORMAT(subdate(CURDATE(), 1), '%Y-%m-%dT04:00:00'), '+00:00', '-04:00'), '%Y-%m-%d %H:%i'), '%Y-%m-%d %H:%i') AND str_to_date(date_format(convert_tz( DATE_FORMAT(CURDATE(), '%Y-%m-%dT03:59:00'), '+00:00', '-04:00'), '%Y-%m-%d %H:%i'), '%Y-%m-%d %H:%i')
    AND `leads`.`source` = 4
  )
LIMIT 2000


Where I need to translate to codeigniter format.

Also, if possible, I have to make the CURDATE() be a dynamic date variable which I include - meaning I could include any date range and it would change the query accordingly. Anyone have any ideas on how I can do this? Thanks
Reply


Messages In This Thread
Convert my sql query to codeigniter syntax - by andreaccident - 07-06-2020, 08:15 AM



Theme © iAndrew 2016 - Forum software by © MyBB