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
get url?
how do i get the url of the page i'm currently on, on my website.. i think its get header.. how do i
Remove directories not empty
hi,
i have an array that contains some names (1,4,6,56...). Every integer is a name of a folder.<
Got A Free Server :(
So I was given a free server
http://shopping.yahoo.com/p:Compaq%20ProLiant%201500%20Server:1
Could Someone Please Debug This?
I was wondering if someone could debug this script for me. I realize it's not the tidest script (and
asking for direction
I have 2 tables in my data, which are "post" and "event"
I won't make a summa
Apart from cron
I need to run a php file every one hour. Is there any other solution apart from cron job?
Warning: Cannot modify header information - headers already sent by (output sta
Warning: Cannot modify header information - headers already sent by (output started at /home/praylif
XML Grouping
I'm using xml_parse_into_struct to get all my elements, but now I need to group them. For example, h
Multiple upload and Resize
I would like some help on my script I have the for my index.php
////
<html&
Shuffle Array
Hi,
I am writing a script for a game that needs players to randomly be assigned a target (ano