The DaysAfter function works fine if the the two dates are at least one day
apart.
But SecondsAfter doesn't do a lot of good if there is a date rollover.
For example, datetime1 is 02/27/2008 23:45:00 and datetime2 is 02/28/2008
00:15:00. A simple powerbuilder built-in function as
datetimediff(date1,date2) should give me 1,800 seconds. But subtracting the
dates gives me -1 and subtracting the times gives me -84600.
My head spinneth!!
Can someone help me? I expect that this is easy, but my brain does not
function well with date roll overs!
Note to Sybase: A built-in function to handle this and other datetime
related functions would be nice.
I have this nice function that gajender_99 helped out with at
experts-exchange.com.
Give it a date, a time horizon in hours and it gives you the end datetime
(AND HANDLES THE MIDNIGHT ROLLOVER). This is all quite arcane. Everyone
needs to do this stuff. Why does not Sybase make it easy to do!?
datetime start_pickupdatetime,end_pickupdatetime
date vl_today
time vl_now
long horizon,vl_hour,vl_min,vl_ss
string vl_time
horizon = long(ddlb_horizon.text)
vl_now=now()
vl_today=today()
vl_min=minute(vl_now)
vl_hour=hour(vl_now)
vl_ss=second(vl_now)
vl_hour=vl_hour + horizon
if vl_hour>=24 then
vl_hour=vl_hour - 24
vl_today=relativedate(vl_today,1)
vl_time=string(vl_hour)+':'+string(vl_min)+':'+string(vl_ss)
end_pickupdatetime = DATETIME(vl_today,time(vl_time))
Else
vl_time=string(vl_hour)+':'+string(vl_min)+':'+string(vl_ss)
end_pickupdatetime = DATETIME(vl_today,time(vl_time))
End if
//horizon = long(ddlb_horizon.text) * 60 * 60
messagebox("horizon is",string(horizon))
start_pickupdatetime = DATETIME(today(), vl_now)
dw_1.retrieve(start_pickupdatetime,end_pickupdatetime)
long a = currentTimeMillis()
....
long b = currentTimeMillis()
totalSecond = (b-a) / 1000
totalMinute = (b-a)/1000/60
++OIL
"Paul Murray" <pemu...@staysystems.com> 撰寫於郵件新聞:47c60c8c$1@forums-1-dub...
ll_hours = DaysAfter (date (ldt_1), date (ldt_2)) * 24.0 + SecondsAfter
(time (ldt_1), time (ldt_2)) / 3600.0 + .5
HTH
Daniel.
"Daniel Jenkins" <danieldotje...@gacnospamworld.com>
???????:47C65F0F...@gacnospamworld.com...
Ken
"Daniel Jenkins" <danieldotje...@gacnospamworld.com> wrote in
message news:47C65F0F...@gacnospamworld.com...
Daniel, I had to take off the '+ .5' at the end of the calculation, but it
works perfectly. I defined ll_hours as decimal. I guess you were giving it
a 30 minute buffer.
Again, my most sincere thanks!!
Goose, thanks for diving in as well.
Paul
"Daniel Jenkins" <danieldotje...@gacnospamworld.com> wrote in
message news:47C65F0F...@gacnospamworld.com...