Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > PHP/MySQL > MySQL
Password Reminder
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
MySQL General discussion about the MySQL database.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the MySQL section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old November 25th, 2006, 08:37 PM
Authorized User
Join Date: Oct 2006
Location: , , .
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default SQL Programming - Play around with date


Let say, i've these following table:-

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

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.

Reply With Quote
  #2 (permalink)  
Old November 27th, 2006, 08:15 AM
Registered User
Join Date: Oct 2006
Location: Amman, , Jordan.
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Mahmoud82

i need it too plz any body help us.
Reply With Quote
  #3 (permalink)  
Old December 11th, 2006, 03:37 AM
Authorized User
Join Date: Nov 2006
Location: Bhopal, MP, India.
Posts: 31
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to talk2leo

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
Reply With Quote
  #4 (permalink)  
Old December 14th, 2006, 07:15 AM
Authorized User
Join Date: Oct 2006
Location: , , .
Posts: 60
Thanks: 0
Thanked 0 Times in 0 Posts

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 ;))

Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Play around with date wkm1925 SQL Language 1 November 27th, 2006 08:30 AM
Need Help Programming a Date Comparison Database jackson_jl Beginning VB 6 0 March 7th, 2005 03:03 PM
SQL Programming Scorcel Forum and Wrox.com Feedback 2 August 14th, 2004 12:15 AM
Convert String Date to Date for a SQL Query tdaustin Classic ASP Basics 4 July 7th, 2003 06:01 PM

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

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