Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How view remaining months.

Status
Not open for further replies.

raynoel

Programmer
Jul 10, 2006
8
PH
I was able to get the expiry date of a certain company in
my database but I have problem on how to view their remaining months before the expiry date.

I have function name kh_expiry which check the expiry date of a company.

SELECT DISTINCT kh_expiry(enrollmentdate), companyidfk FROM enrollment WHERE companyidfk = 101 AND enrollmentstatusidfk = 0;

I tried to have

SELECT DISTINCT kh_expiry(enrollmentdate)-current_date, companyidfk FROM enrollment WHERE companyidfk = 101 AND enrollmentstatusidfk = 0;

i subtract the expiry to the current date but the result gives me like 3 digit numeric, 291 ....

Pleaase help...
thnx!
 
Is your kh_expiry function a plpgsql function? If you are returning a date value, I believe the difference is going to yield you value of type 'interval'. Use the pl functions to convert your interval value.

Hope that helps,
Gary
gwinn7
 
Thanks for your reply gwinn7 but im confuse on how to use the interval time.. can you provide me example on how for the query below,

SELECT DISTINCT kh_expiry(enrollmentdate)-current_date, companyidfk FROM enrollment WHERE companyidfk = 101 AND enrollmentstatusidfk = 0;

The kh_expiry uses the plpgsql language but it's manually encoded...

PLs help... thanks...
 
The help system can explain it better and more thoroughly than I can.

Do a quick lookup on "interval", or "date". You should be able to find a reference with examples of how this is manipulated.

Gary
gwinn7
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top