473,465 Members | 1,860 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Time Calculation

Rob
I would like to display the difference between the logging time
[Session("start"] and the current time [now]. In hours minutes and seconds,
I have tried a couple of things but all I see is gobbledy gook.

Any guidance would be appreciated.

Regards,

Rob
Jul 22 '05 #1
4 1941
Rob wrote:
I would like to display the difference between the logging time
[Session("start"] and the current time [now]. In hours minutes and
seconds, I have tried a couple of things but all I see is gobbledy
gook.

Any guidance would be appreciated.


Assuming, in global.asa, you have:
Sub Session_onstart()
Session("start") = Now
End Sub

In your asp page, you would calculate the difference in seconds:

dim timelogged
timelogged = datediff("s",cdate(Session("start")), Now)

Then calculate the hours, min. etc from that:

dim hourslogged
hourslogged=timelogged\3600

I'll leave the rest as "an exercise for the student".
Let us know if you need help with the rest. I think there is an article
about doing this at aspfaq, but I'm not sure.

Bob Barrows
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
Jul 22 '05 #2
Function GetAgeStamp(dtmStartDate)
If IsDate(dtmStartDate) Then
intDays = 0
intHours = 0
intMinutes = 0
dblTotalSeconds = DateDiff("s",dtmStartDate,Now())
If dblTotalSeconds >= 86400 Then intDays = dblTotalSeconds \ 86400
If intDays > 0 Then dblTotalSeconds = dblTotalSeconds Mod 86400
If dblTotalSeconds >= 3600 Then intHours = dblTotalSeconds \ 3600
If intHours > 0 Then dblTotalSeconds = dblTotalSeconds Mod 3600
If dblTotalSeconds >= 60 Then intMinutes = dblTotalSeconds \ 60
If intMinutes > 0 Then dblTotalSeconds = dblTotalSeconds Mod 60
Dim ar(3)
ar(0) = Right("0" & intDays,2)
ar(1) = Right("0" & intHours,2)
ar(2) = Right("0" & intMinutes,2)
ar(3) = Right("0" & dblTotalSeconds,2)
GetAgeStamp = Join(ar,":")
End If
End Function

--
'dlbjr
'Pleading sagacious indoctrination!
Jul 22 '05 #3
dlbjr wrote:
Function GetAgeStamp(dtmStartDate)
If IsDate(dtmStartDate) Then
intDays = 0
intHours = 0
intMinutes = 0
dblTotalSeconds = DateDiff("s",dtmStartDate,Now())
If dblTotalSeconds >= 86400 Then intDays = dblTotalSeconds \ 86400
If intDays > 0 Then dblTotalSeconds = dblTotalSeconds Mod 86400
If dblTotalSeconds >= 3600 Then intHours = dblTotalSeconds \ 3600
If intHours > 0 Then dblTotalSeconds = dblTotalSeconds Mod 3600
If dblTotalSeconds >= 60 Then intMinutes = dblTotalSeconds \ 60
If intMinutes > 0 Then dblTotalSeconds = dblTotalSeconds Mod 60
Dim ar(3)
ar(0) = Right("0" & intDays,2)
ar(1) = Right("0" & intHours,2)
ar(2) = Right("0" & intMinutes,2)
ar(3) = Right("0" & dblTotalSeconds,2)
GetAgeStamp = Join(ar,":")
End If
End Function


Awwww - you spoiled Rob's exercise. Now he'll never discover whether or not
he could have written this himself ...
;-)

Why did you reply to me? I've already got a similar function in my library
....

Bob Barrows
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
Jul 22 '05 #4
Drinkin' to heavy I guess. Should take on a light beer!

Sorry Bob

--
'dlbjr
'Pleading sagacious indoctrination!
Jul 22 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: anaxamandr | last post by:
Hi. I have a long loop in ASP that performs a rather lengthy calculation. I would love for my users to be able to stop that calculation, if they so choose, mid way through the process. I attempted...
5
by: Tom | last post by:
A field in a data set I want to import into Access is in Unix time (seconds from a certain time on a certain date). Does anyone know the precise date and the precise time on that date that Unix is...
5
by: cvisal | last post by:
Hi all Im working on productivity calculations (Time calculations) and need some help in coding. Database Tool:MS-Access 2003. The general operator punch-in time is 5:30 AM and the punch-out...
10
by: Drum2001 | last post by:
I have designed a "Time Tracker Database"... Basically a Time Clock. I have report that calculates the number of regular hours worked per week. Currently I am running the following query: ...
8
by: andreas | last post by:
Hi, I have a calculation program in vb.net who is running for let us say for more than a hour. When I will do meanwhile something els in a office program I see that my calculation program takes a...
5
by: The alMIGHTY N | last post by:
Hi all, Let's say I have a simple math formula: sum (x * y / 1000) / (sum z / 1000) I have to do this across 50 items, each with an x, y and z value, when the page first loads AND when a...
3
by: Gretsch | last post by:
Web, html, javascript, Hi, I need to calculate the time since this .htm file was last modified. {which I can then use in a calculation, rather than display, so days&decimals format would be OK}...
1
by: juliacjy | last post by:
Dear all, I'm needing an urgent help. I'm now maintaining a system which has a function of "Automatic Calculation". User is allowed to set of a time which then will be stored in one of my sql...
6
by: Lara1 | last post by:
I'm trying to get certain cells to show a hovering alert message when I click on them. (I don't want an error-message style box to pop up, because I'll eventually want it to show for lots of cells...
2
by: John Torres | last post by:
I created a form with “Time In1”, “Time Out1”, “Time In2”, “Time Out2”. I’m able to calculate the time correctly when it was during the day shifts from 7:00 AM (Time In1) 5:00 PM (Time Out1) = 10:00...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.