Forums

ASP

This topic is locked

Date diff function

Posted 15 Apr 2002 21:19:33
1
has voted
15 Apr 2002 21:19:33 Matthijs Horsman posted:
Hello all,

I am trying to mess around with some date varibles with the diffdate function
Works out pretty nice BUT i can'y seem to get the right output!

Say i have these two dates:

01-01-2002 23:15 (DD/MM/YYYY and time)
02-01-2002 12:00

and i want it to become 12,30 (twelve hours and 30 minutes)

My code know is
<% '=DateDiff("n", 01-01-2002 23:30, 02-01-2002 12:00)/60 %>

wich results in 12,50 which is ok, but i need it to be 12,30 (twelve hours and 30 minutes)

I tried to use the replace function like this:

<%= replace(DateDiff("n", sd, ed)/60, 75, "45" %>
Wichh works out great for al the numbers that have to be reduced from 75 to 45 but thats only one (i am gone work in whole quarters so i only need to add 15, 30 and 45) but maybe there's another way....

Thanks in advance

Grrrr
Matthijs
----------------
UD4/WY2K/IIS/ASP-VB

Replies

Replied 16 Apr 2002 05:08:33
16 Apr 2002 05:08:33 Hank Tan-Tenn replied:
You mean you don't want to know the exact difference between DateTime1 and DateTime2 but want to round off the difference to the nearest quarter-minute? If so, what are your criteria for rounding?

e.g. If the difference is 12 hours and 14 minutes, do you round it to 12:15 or 12:00?

Hope I haven't totally misunderstood....

[edited]

I think I understand the problem now:

I'd use int(datediff(...etc.)/60) to get the "12" (in your example) and use MOD(datediff(...etc.)/60) to get "30".

Edited by - akc on 16 Apr 2002 05:20:50
Replied 16 Apr 2002 10:53:59
16 Apr 2002 10:53:59 Matthijs Horsman replied:
Hi AKC,

Thans for the info, but i am still a little confused about the MOD thing.

The thing i tried to do was the following.

In the example i gave the results were 12,5. The ,5 stands for half an hour, but i want that he gives the half an hour for real, so instead of ,5 it has to be ,30 like an half hour or ,15 for a quarter in stead of ,25. You know it's like the two different metric systems, the hours go to 60 min and the normal counting go to 100....

Hope this clears it all up a little.

If i can use this MOD function for this, can you explain what that is, and how i can use it?

(i am gonna go on vacation, for a week, so can you please send it to my e-mail adres? Thanks)



Grrrr
Matthijs
----------------
UD4/WY2K/IIS/ASP-VB

Reply to this topic