Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

The Database Forum


You are currently viewing our The Database Forum as a guest. Please register to participate.
Login



Reply
semi complicated query, anyone done this?
Old 02-15-2009, 09:28 PM semi complicated query, anyone done this?
Banned

Posts: 34
Trades: 0
hey guys , i cant get my head around his one, here is the query

SELECT acdate,CONCAT(DAYOFYEAR(acdate)-DAYOFYEAR(NOW()),' days ', DATE_FORMAT(ADDTIME("2000-00-00 00:00:00",
SEC_TO_TIME(TIME_TO_SEC(acdate + INTERVAL ktime DAY)-TIME_TO_SEC(acdate))),'%k hours and %i minutes')) AS time FROM tblproduct WHERE DATE_SUB(CURDATE(),INTERVAL 5 DAY) <= acdate;

acdate holds the date when a product was created, ktime holds an integer value on the amount of days a product is allowed to be active. the query above supposed to return the records from the last 5 days, and display the days hours between acdate and acdate + days, so it would say "3 hours 2min left till listing ends" , the query so far returns 0 for hours and minutes.

any clues?
Necaxa is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 02-24-2009, 07:19 PM Re: semi complicated query, anyone done this?
Junior Talker

Posts: 3
Trades: 0
Forgive me if I'm just blindly jumping in here but it looks like you're subtracting
Code:
DAYOFYEAR(acdate)-DAYOFYEAR(NOW())
The epoch started in about 1970 somewhere starts at zero seconds... the more recent the date/time, the higher the number. You're subtracting a date that could be seconds, days, weeks, months, or years old with the current date "NOW" which will always have a higher number and always return 0 (unless mysql time functions can return a negative integer that you could get the absolute value of) Try switching those two around so it's
Code:
DAYOFYEAR(NOW())-DAYOFYEAR(acdate)
__________________
providing business solutions .....
Please login or register to view this content. Registration is FREE
tmijs789 is offline
Reply With Quote
View Public Profile
 
Old 02-24-2009, 07:32 PM Re: semi complicated query, anyone done this?
Decaf's Avatar
Ultra Talker

Posts: 489
Name: Adam
Trades: 0
Quote:
Originally Posted by tmijs789 View Post
Forgive me if I'm just blindly jumping in here but it looks like you're subtracting
Code:
DAYOFYEAR(acdate)-DAYOFYEAR(NOW())
The epoch started in about 1970 somewhere starts at zero seconds... the more recent the date/time, the higher the number. You're subtracting a date that could be seconds, days, weeks, months, or years old with the current date "NOW" which will always have a higher number and always return 0 (unless mysql time functions can return a negative integer that you could get the absolute value of) Try switching those two around so it's
Code:
DAYOFYEAR(NOW())-DAYOFYEAR(acdate)
January 1st 1970 00:00:00 GMT.
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE

Decaf is offline
Reply With Quote
View Public Profile Visit Decaf's homepage!
 
Reply     « Reply to semi complicated query, anyone done this?
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.38974 seconds with 12 queries