Find time remaining from Date in database

fpineda101

Well-known member
Joined
Nov 14, 2005
Messages
122
Location
Los Angeles, CA
Programming Experience
1-3
I would like to know how to Select a date from a DB and then subtract Now or SYSDATE(Oracle DB) from the Selected date to display time remaining similiar to an ebay auction. Please help! Any advice is appreciated
 
Figured it out!

This code works for Oracle...

select trunc((datecreated + 7)-sysdate ) || ' days ' ||
trunc( mod( ((datecreated + 7)-sysdate )*24, 24 ) ) || ' hours ' ||
trunc( mod( ((datecreated + 7)-sysdate )*24*60, 60 ) ) || ' minutes ' ||
trunc( mod( ((datecreated + 7)-sysdate )*24*60*60, 60 ) ) || ' seconds remain'
FROM table_name
WHERE <your where condition here>
 
Back
Top