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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

difference between two time stamp 1

Status
Not open for further replies.

ankursaxena

Programmer
Sep 7, 2001
133
US
Hi! i had an earlier question about timpe stamp to figure out the month, now i also want to know if i have time stamp say start and end and i want to find the difference/duration between the two how do i do that? i can assume that the first YYYYMMDD remains constant but if it is independent of this fact, can we find the difference, please some one help..i have been trying but cant find it.

thanx for all the help

Ankur
 
Play with these, they should help:
select @start:=dayofyear('2002-01-13') as start,@end:=dayofyear('2002-06 -30') as end,@interval:=(@end - @start) as days_between;

select @start:=dayofyear(date_sub(curdate(), interval 100 day)) as start ,@end:=dayofyear(date_add(curdate(),interval 100 day)) as end,@interval:=(@end - @start) as days_between;

curdate() is today.
date_sub(curdate(), interval 100 day) will take 100 days off today.

dayofyear(your_date_field) will return the day number of the stamp, get two and take one from the other = number of days between.

there are lots more ways to do this, this happened to be on my mind at the moment tho :) ***************************************
Party on, dudes!
[cannon]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top