Filling gaps in dates


Posted on 16th Feb 2014 07:03 pm by admin

So i'm doing a query for sales data and my return array looks like this

('date' => '2008-11-01 00:00:00', 'total' => 1),
('date' => '2008-11-03 00:00:00', 'total' => 3),
('date' => '2008-11-04 00:00:00', 'total' => 3),
('date' => '2008-11-07 00:00:00', 'total' => 5),
('date' => '2008-11-12 00:00:00', 'total' => 1)

There are obviously gaps in my dates. What i'm trying to figure out is the best approach to filling those empty dates with a total of 0 so my graphs don't look all jacked up because i'm not providing all the data. Does anyone have an idea how to approach this problem to fill in the missing dates? I'd like the array to look like the following:


('date' => '2008-11-01 00:00:00', 'total' => 1),
('date' => '2008-11-02 00:00:00', 'total' => 0),
('date' => '2008-11-03 00:00:00', 'total' => 3),
('date' => '2008-11-04 00:00:00', 'total' => 3),
('date' => '2008-11-05 00:00:00', 'total' => 0),
('date' => '2008-11-06 00:00:00', 'total' => 0),
('date' => '2008-11-07 00:00:00', 'total' => 5),
('date' => '2008-11-08 00:00:00', 'total' => 0),
('date' => '2008-11-09 00:00:00', 'total' => 0),
('date' => '2008-11-10 00:00:00', 'total' => 0),
('date' => '2008-11-11 00:00:00', 'total' => 0),
('date' => '2008-11-12 00:00:00', 'total' => 1)

No comments posted yet

Your Answer:

Login to answer
234 Like 46 Dislike
Previous forums Next forums
Other forums

building a function with multiple outputs
I want to build a function that has multiple outputs.

I know but am not to sure how I should

Taking an HTML form and a PHP program and making it into one working file.
Hello,

So I would like to display everything INSIDE a specific directory. In other words, I

checkbox update
I am having a brain fart right now and i cant remember how to do this. if anyone could help that wou

Search in the PHP Files
have to search asterisk(*) in the php code of the php files .
In the html page one text box

Java API in PHP?
I have an application that we use internally here at the office.

The software company provide

Need help with a mail notify function
I was tasked with setting up a site that's been prewritten. The site is basically a form that captur

Dump with added_funcion cl_salv_table
Hi there, I'm having some troubles adding a self defined function to an ALV in fullscreen. The thing

Converting numbers to months
The porgram works -just need the last function(month_convert_ to convert numbers to months -thanks.

Need help: how to catch acess of undefined class properties
Hello. I am learning OO with PHP and have hit a problem.
Some code runs as perfectly valid code,

Help with echo()
I'm having some problems with this code:

Code: echo '
<A HREF="jav

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash