Calculating a Result of difference between 2 date

# Thread: Calculating a Result of difference between 2 date

1. Senior Member
Join Date
Dec 1969
Posts
146

## Calculating a Result of difference between 2 date

I was working on building a function to do this but rather than reinvent the wheel, I thought I would ask if any one had any functions already written. <BR><BR>I have two fields: <BR>StartDate 12/20/2004 08:30 <BR>EndDate 12/21/2004 10:35 <BR><BR>Basically, I want the result of the difference to be displayed as <BR>01:02:05 <BR><BR>(dd:hh:mm) <BR><BR>Any ideas? <BR><BR>*Please note, I also posted this in the asp forum but got slapped so I moved it here. I would not normally post the same thing twice :)

2. Senior Member
Join Date
Dec 1969
Posts
146

## My hack is almost working

difference=resolved - assign <BR>days= day(difference) + 1 <BR>hours= hour(difference) <BR>minutes=minute(difference)<BR>response.write days & ":" & hours & ":" & minutes<BR><BR><BR>returns 13:1:1 instead of 13:01:01<BR><BR>The dates I am using are: <BR>12/12/2004 12:24<BR>12/25/2004 13:25<BR><BR>Any suggestions?<BR><BR>Thanks

3. God
Senior Member
Join Date
Dec 1969
Posts
18,177

## If you simply ...

.. now just want a preceding 0, that&#039;s easy:<BR><BR>response.write days & _<BR> ":" & _<BR> Right("00" & hours, 2) & _<BR> ":" & _<BR> Right("00" & minutes, 2)

4. Senior Member
Join Date
Dec 1969
Posts
96,118

## That's no good

Try these two entries:<BR> 12/25/2004 1:10 PM<BR> 12/25/2004 2:20 PM<BR><BR>What do you get?<BR><BR>With your code, I get 31 days.<BR><BR>Now change it to<BR> days = INT( difference )<BR><BR>Not 100% sure, but I think that works, then.

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•