p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   MySQL (http://p2p.wrox.com/forumdisplay.php?f=99)
-   -   SQL Programming - Play around with date (http://p2p.wrox.com/showthread.php?t=50758)

wkm1925 November 25th, 2006 08:37 PM

SQL Programming - Play around with date
 
Hi,

Let say, i've these following table:-

licenses
TransID | VehicleID | DateApproved
----------------------------------------
1 | AU2985 | 2004-10-13
2 | BX3290 | 2005-09-28
3 | UJ5345 | 2006-10-13
* The above VehicleID is unique.



licenses_renew
TransID | VehicleID | RenewDate
----------------------------------------
1 | AU2985 | 2005-10-18
2 | BX3290 | 2006-09-29
3 | AU2985 | 2006-10-19

DateApproved will expires after 1 year. RenewDate also will expires after 1 year.

Assume, current system date is 2005-11-26. The expected result shown these following:-
VehicleID | DateApproved_RenewDate | ExpiredDate | Status
----------------------------------------------------------------------
AU2985 | 2004-10-13 | 2005-10-13 | Need to renew
AU2985 | 2005-10-18 | 2006-10-18 | Need to renew
AU2985 | 2006-10-19 | 2007-10-19 | Still Valid
BX3290 | 2005-09-28 | 2006-09-28 | Need to renew
BX3290 | 2006-09-29 | 2007-10-29 | Still Valid
UJ5345 | 2006-10-13 | 2007-10-13 | Still Valid

How to query that?
Please help me.


Mahmoud82 November 27th, 2006 08:15 AM

i need it too plz any body help us.

talk2leo December 11th, 2006 03:37 AM

do u want repeated entries to be shown in ur result or not..
as u have 3 all of ure results are repeated. i mean 1st is repeated 3times.2nd record 2 times..if want like this then tell me or ir no then also tell me..

Success is Never Ending,,Failure is Never Final

jhanny007 December 14th, 2006 07:15 AM

this is problem very complex you are trying to get the expired date right?

use loop to determine and to get the result but it seems that your adding another variable name which can make error in your database table....

use while loop or for loop

i hope this can help ;))



All times are GMT -4. The time now is 04:55 PM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.