SugarQuery and timezone

I'm having trouble with SugarQuery not returning the correct number of records due to Timezone.

The database is storing the dates in UTC but it's showing the correct date and time in my local time when using Sugar, as expected.

However, in the code below, the number of records between start_date and end_date are correct only if start_date and end_date are assumed to be UTC.

dateBetween() seems to only take date and ignore time so I can't convert to/from UTC accurately either.

gte() & lte() also don't seem to work correctly because these are dates and not numbers.

What am I missing?

$query = new SugarQuery();
$query->select(array('id'));
$query->from(BeanFactory::newBean('Leads'));
$query->where()->equals('project_leads_1_name', $bean->project_allocated_c);
$query->where()->dateBetween('next_call_c', array($bean->start_date,$bean->end_date));
//$query->where()->queryAnd()->gte('next_call_c',$bean->start_date)->lte('next_call_c',$bean->end_date); // doesn't work correctly
$bean->total_calls_due_c = count($query->execute());

Parents Reply Children
No Data