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
46
Other forums
help with image upload code
Hello,
right now this code I have resizes images and then places them into the uploads folder
Does design fit in FPGA ?
Hi all,
I've made a large HCC-Design. Because of the program-size the compile process with th
highlighting search terms
well, I started this in the regular PHP section, but it no longer fits there. Suffice it to say, I'm
PHP hyperlinks generator
Hi
I need some help to get this done using php:
1 - I have few hyperlinks say 500
MySQL noob question
hi guys
I have a simple mysql table set up, along the lines of
Col 1 - Col 2 - Date_l
How to create a static html menu from a database
Hi,
I have built a small cms which allows me to create simple html pages and then upload them
Transaction variant for VA02 not working
My requirement is to have transaction for user to only add the output and print a sales order.
Alternate messaging
I have 4 strings in MySQL db1
$string1 : Hello
$string2 : Hi
$string3 : Great
$strin
php is not recognized as an internal or external command
Hello,
I am trying to bake the code in CakePHP through my console.
I have changed my Path
How to pass parameter to tag query?
Hi,
I want to get the value of a tag at a specific time (like 10/27/09 15:29:59), I need to giv