rami103 Posted June 20, 2010 Share Posted June 20, 2010 hi friends i need lil help in php reports i have a sales tabel where i have sale_id and sale_price and date_added columns i want to show a chart on my page showing last 6 months with number of sales can someone suggest me or give me some example how i can do i have chart code but i dont know how i can get last 6 months with number of sales from database thanks Quote Link to comment Share on other sites More sharing options...
pengu Posted June 21, 2010 Share Posted June 21, 2010 hi friends i need lil help in php reports i have a sales tabel where i have sale_id and sale_price and date_added columns i want to show a chart on my page showing last 6 months with number of sales can someone suggest me or give me some example how i can do i have chart code but i dont know how i can get last 6 months with number of sales from database thanks SQL query, using your date_added column. Quote Link to comment Share on other sites More sharing options...
ohdang888 Posted June 21, 2010 Share Posted June 21, 2010 in your SQL query, in the Where clause, you need something like this WHERE (UNIX_TIMESTAMP(NOW()) - UNIX_TIMESTAMP(`date_added`)) < (60*60*24*182) that set of numbers is the number of seconds in half a year (ish)... so whatever you do needs to follows this logic: number of seconds since epoch to right now - number of seconds since epoch to the date added must be less than the number of seconds in 1/2 of a year (60 seconds * 60 min * 24 hr * 182 days) Quote Link to comment Share on other sites More sharing options...
rami103 Posted June 21, 2010 Author Share Posted June 21, 2010 thanks ohdang888 its really helpful thanks Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.