Creating SQL report

Creating SQL report

by Ned Stark -
Number of replies: 2

Hi guys, 

I am trying to create a report where we can see course completion date and the date when it will expire. Here is what I got so far:

SELECT u.firstname AS 'Firstname' , u.lastname AS 'Lastname', c.fullname AS 'course',

DATE_FORMAT(FROM_UNIXTIME(p.timecompleted

),'%Y-%m-%d') 

AS completed

FROM prefix_course_completions AS p

JOIN prefix_course AS c ON p.course = c.id

JOIN prefix_user AS u ON p.userid = u.id

WHERE c.enablecompletion = 1

ORDER BY u.firstname


Can someone show me how to add 365 days on the completion date above? I will appreciate any suggestions.


Thanks,
Ned

Average of ratings: -
In reply to Ned Stark

Re: Creating SQL report

by Ned Stark -

hi pls help

In reply to Ned Stark

Re: Creating SQL report

by Ned Stark -

I will help myself now. Advance thank you to myself.

SELECT u.firstname AS 'Firstname' , u.lastname AS 'Lastname', cat.name AS 'Organisation', c.fullname AS 'course',
DATE_FORMAT(FROM_UNIXTIME(p.timecompleted),'%Y-%m-%d') AS completed,
DATE_FORMAT(DATE_ADD(FROM_UNIXTIME(p.timecompleted),INTERVAL 1 YEAR), '%Y-%m-%d') AS expiration_date
FROM prefix_course_completions AS p
JOIN prefix_course_categories AS cat 
JOIN prefix_course AS c ON p.course = c.id
JOIN prefix_user AS u ON p.userid = u.id
WHERE c.enablecompletion = 1
ORDER BY u.firstname
Average of ratings: Useful (3)