PDA

View Full Version : Date Order Issue and Dynamic Dates...


iamdan356160
12-08-2010, 10:34 AM
Hi all,
I have 2 quick questions...

Number 1 - Date Order Issue...
I have a field in my database named 'User_JoinDate' and the date is being written in the following format yyyy-mm-dd. For some reason, when the dates are displayed in the chart generated by DWC, they appear in the following order...
Dec 5,2010
Dec 6,2010
Dec 7,2010
Dec 8,2010
Dec 2,2010
Dec 3,2010

Any ideas why the dates are not ordering them self correctly?

Number 2 - Adding dynamic dates to mySQL statement...
Currently my SQL statement looks like this...

WHERE User_JoinDate >= '2010-12-02' AND User_JoinDate <= '2010-12-08' AND User_AccountType = 'free'

How can I write this statement so that the dates are not hard coded? For example... the 'Date From' to be dynamically written to 7 days ago from today's date and the 'To Date' dynamically written to be today's date? Does that make sense?

Any help would be greatly appreciated! Thanks in advance!

Dan

Jason Byrnes
12-09-2010, 08:11 AM
Do you have an order by clause in the SQL:
WHERE User_JoinDate >= '2010-12-02' AND User_JoinDate <= '2010-12-08' AND User_AccountType = 'free' ORDER BY User_JoinDate ASC



you can use the MySQL CURDATE() command to return the currant date and use DATE_SUB to subtract 7 days
CURDATE()
DATE_SUB(CURDATE(),INTERVAL 7 DAY)

or
WHERE User_JoinDate >= 'DATE_SUB(CURDATE(),INTERVAL 7 DAY)' AND User_JoinDate <= 'CURDATE()' AND User_AccountType = 'free' ORDER BY User_JoinDate ASC



see the mysql page for more details on date and time functions:
http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html

iamdan356160
12-09-2010, 08:53 AM
Thank Jason...
My SQL had (written by DWC)... 'ORDER BY DAYOFWEEK(User_JoinDate) ASC'
Changed it to your suggestion and its put them in the correct order!...

Also the date function works great! Thought I do have another quick question...

If these are the dates in the records that are pulled into the chart... you'll notice that the 4th December is missing...

Dec 2,2010 = 9 Users
Dec 3,2010 = 3 Users
Dec 5,2010 = 3 Users
Dec 6,2010 = 5 Users
Dec 7,2010 = 2 Users
Dec 8,2010 = 1 Users

because no one signed up on that day. I want the chart to be able to show the last 7 days of activity... So I'd like the 4th to appear in the chart... but show that there were zero records on that day OR if no one signed up all week, it would just show a flat line of along the 0 axis. How can I do this??

Jason Byrnes
12-09-2010, 08:57 AM
the chart can only display value s that are in the database. It cannot show values that dont exist in the database.

iamdan356160
12-09-2010, 09:15 AM
Why is it when I remove all free members for the past 7 days I get 2 instances of the line that reads... '# of free members per week?' Please see attached example...
Thank you!

Jason Byrnes
12-09-2010, 09:26 AM
honest answer: I dont know.


send a copy of your page and a copy of the DynamicWebCharts folder so i can examine the code.

iamdan356160
12-09-2010, 09:31 AM
Here you go... (I've added the page to the same folder - home.php)
Many Thanks,

Dan

Jason Byrnes
12-09-2010, 11:41 AM
i cant see anything in the code to cause this nor can i reproduce it.


can you send a link?

iamdan356160
12-09-2010, 02:37 PM
Can you send me a direct email address that I can send login details to please Jason?

Jason Byrnes
12-14-2010, 09:37 AM
I have created a support ticket so we can look into this issue further.

To view and edit your support ticket, please log into your support history:
http://www.webassist.com/mywebassist/supporthistory.php