473,394 Members | 1,722 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Add Times?

I have modified the ASP.NET TimeTracker Starter Kit to include the ability
for users to log working hours (Start Time, Finish Time, Lunch Duration).
This is then presented to them in a grid & a TimeWorked column is calculated
(in a UDF within the DB).

I want to include a label in the footer of TimeWorked which will show the
TotalTimeWorked in the format HH:mm (e.g. 37:30).

All of these TimeWorked values are returned in the format #1/1/1900
7:30:00AM# which indicates a total of 07:30 for the day. This is formatted
in the grid & displays as desired.

I notice that you can subtract one datetime from another, but you can only
add a timespan a datetime. I therefore created a timespan by subtracting
#1/1/1900 00:00:00# from the TimeWorked value. I then added this timespan to
a Total timespan. Unfortunately, this does not appear to calculate correctly
with example values:

TimeWorked
07:50
11:25
08:00
07:50
05:40

As I loop through these the values in tsTotal are:
tsTotal.Hours:tsTotal.Minutes
7:50
19:15
3:15 (Starts going wrong here?)
11:5
16:45
How can I add these values to get the Sum(TimeWorked)?

--
Cheers,

James Goodman
Nov 19 '05 #1
6 1712
Hi James,

You don't want to add times. You want to subtract them. Subtracting the
Start Time from the End Time will result in a TimeSpan of the difference
between them Subtracting LunchDuration from that TimeSpan will give you the
net time worked.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Sometimes you eat the elephant.
Sometimes the elephant eats you.

"James Goodman" <jamesATnorton-associates.co.ukREMOVE> wrote in message
news:Oi*************@TK2MSFTNGP14.phx.gbl...
I have modified the ASP.NET TimeTracker Starter Kit to include the ability
for users to log working hours (Start Time, Finish Time, Lunch Duration).
This is then presented to them in a grid & a TimeWorked column is
calculated (in a UDF within the DB).

I want to include a label in the footer of TimeWorked which will show the
TotalTimeWorked in the format HH:mm (e.g. 37:30).

All of these TimeWorked values are returned in the format #1/1/1900
7:30:00AM# which indicates a total of 07:30 for the day. This is formatted
in the grid & displays as desired.

I notice that you can subtract one datetime from another, but you can only
add a timespan a datetime. I therefore created a timespan by subtracting
#1/1/1900 00:00:00# from the TimeWorked value. I then added this timespan
to a Total timespan. Unfortunately, this does not appear to calculate
correctly with example values:

TimeWorked
07:50
11:25
08:00
07:50
05:40

As I loop through these the values in tsTotal are:
tsTotal.Hours:tsTotal.Minutes
7:50
19:15
3:15 (Starts going wrong here?)
11:5
16:45
How can I add these values to get the Sum(TimeWorked)?

--
Cheers,

James Goodman

Nov 19 '05 #2
I have a SQL UDF which already gives the TimeWorked for each day, but I want
to add these up & display the total for the data in the grid (will normally
be for the selected week).

--
Cheers,

James Goodman
"Kevin Spencer" <ke***@DIESPAMMERSDIEtakempis.com> wrote in message
news:uv**************@tk2msftngp13.phx.gbl...
Hi James,

You don't want to add times. You want to subtract them. Subtracting the
Start Time from the End Time will result in a TimeSpan of the difference
between them Subtracting LunchDuration from that TimeSpan will give you
the net time worked.

--
HTH,

Kevin Spencer
Microsoft MVP
.Net Developer
Sometimes you eat the elephant.
Sometimes the elephant eats you.

"James Goodman" <jamesATnorton-associates.co.ukREMOVE> wrote in message
news:Oi*************@TK2MSFTNGP14.phx.gbl...
I have modified the ASP.NET TimeTracker Starter Kit to include the ability
for users to log working hours (Start Time, Finish Time, Lunch Duration).
This is then presented to them in a grid & a TimeWorked column is
calculated (in a UDF within the DB).

I want to include a label in the footer of TimeWorked which will show the
TotalTimeWorked in the format HH:mm (e.g. 37:30).

All of these TimeWorked values are returned in the format #1/1/1900
7:30:00AM# which indicates a total of 07:30 for the day. This is
formatted in the grid & displays as desired.

I notice that you can subtract one datetime from another, but you can
only add a timespan a datetime. I therefore created a timespan by
subtracting #1/1/1900 00:00:00# from the TimeWorked value. I then added
this timespan to a Total timespan. Unfortunately, this does not appear to
calculate correctly with example values:

TimeWorked
07:50
11:25
08:00
07:50
05:40

As I loop through these the values in tsTotal are:
tsTotal.Hours:tsTotal.Minutes
7:50
19:15
3:15 (Starts going wrong here?)
11:5
16:45
How can I add these values to get the Sum(TimeWorked)?

--
Cheers,

James Goodman


Nov 19 '05 #3
Ah, well, in that case just add them all together as TimeSpans.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Sometimes you eat the elephant.
Sometimes the elephant eats you.

"James Goodman" <jamesATnorton-associates.co.ukREMOVE> wrote in message
news:OH*************@TK2MSFTNGP15.phx.gbl...
I have a SQL UDF which already gives the TimeWorked for each day, but I
want to add these up & display the total for the data in the grid (will
normally be for the selected week).

--
Cheers,

James Goodman
"Kevin Spencer" <ke***@DIESPAMMERSDIEtakempis.com> wrote in message
news:uv**************@tk2msftngp13.phx.gbl...
Hi James,

You don't want to add times. You want to subtract them. Subtracting the
Start Time from the End Time will result in a TimeSpan of the difference
between them Subtracting LunchDuration from that TimeSpan will give you
the net time worked.

--
HTH,

Kevin Spencer
Microsoft MVP
.Net Developer
Sometimes you eat the elephant.
Sometimes the elephant eats you.

"James Goodman" <jamesATnorton-associates.co.ukREMOVE> wrote in message
news:Oi*************@TK2MSFTNGP14.phx.gbl...
I have modified the ASP.NET TimeTracker Starter Kit to include the
ability for users to log working hours (Start Time, Finish Time, Lunch
Duration). This is then presented to them in a grid & a TimeWorked column
is calculated (in a UDF within the DB).

I want to include a label in the footer of TimeWorked which will show
the TotalTimeWorked in the format HH:mm (e.g. 37:30).

All of these TimeWorked values are returned in the format #1/1/1900
7:30:00AM# which indicates a total of 07:30 for the day. This is
formatted in the grid & displays as desired.

I notice that you can subtract one datetime from another, but you can
only add a timespan a datetime. I therefore created a timespan by
subtracting #1/1/1900 00:00:00# from the TimeWorked value. I then added
this timespan to a Total timespan. Unfortunately, this does not appear
to calculate correctly with example values:

TimeWorked
07:50
11:25
08:00
07:50
05:40

As I loop through these the values in tsTotal are:
tsTotal.Hours:tsTotal.Minutes
7:50
19:15
3:15 (Starts going wrong here?)
11:5
16:45
How can I add these values to get the Sum(TimeWorked)?

--
Cheers,

James Goodman



Nov 19 '05 #4
I thought that, but when I added each timespan to my total timespan it went
kind of haywire.

I am not sure if it is because it is going beyond 24 hours & subsequently
trying to count in days?

--
Cheers,

James Goodman
"Kevin Spencer" <ke***@DIESPAMMERSDIEtakempis.com> wrote in message
news:uJ*************@TK2MSFTNGP12.phx.gbl...
Ah, well, in that case just add them all together as TimeSpans.

--
HTH,

Kevin Spencer
Microsoft MVP
.Net Developer
Sometimes you eat the elephant.
Sometimes the elephant eats you.

"James Goodman" <jamesATnorton-associates.co.ukREMOVE> wrote in message
news:OH*************@TK2MSFTNGP15.phx.gbl...
I have a SQL UDF which already gives the TimeWorked for each day, but I
want to add these up & display the total for the data in the grid (will
normally be for the selected week).

--
Cheers,

James Goodman
"Kevin Spencer" <ke***@DIESPAMMERSDIEtakempis.com> wrote in message
news:uv**************@tk2msftngp13.phx.gbl...
Hi James,

You don't want to add times. You want to subtract them. Subtracting the
Start Time from the End Time will result in a TimeSpan of the difference
between them Subtracting LunchDuration from that TimeSpan will give you
the net time worked.

--
HTH,

Kevin Spencer
Microsoft MVP
.Net Developer
Sometimes you eat the elephant.
Sometimes the elephant eats you.

"James Goodman" <jamesATnorton-associates.co.ukREMOVE> wrote in message
news:Oi*************@TK2MSFTNGP14.phx.gbl...
I have modified the ASP.NET TimeTracker Starter Kit to include the
ability for users to log working hours (Start Time, Finish Time, Lunch
Duration). This is then presented to them in a grid & a TimeWorked
column is calculated (in a UDF within the DB).

I want to include a label in the footer of TimeWorked which will show
the TotalTimeWorked in the format HH:mm (e.g. 37:30).

All of these TimeWorked values are returned in the format #1/1/1900
7:30:00AM# which indicates a total of 07:30 for the day. This is
formatted in the grid & displays as desired.

I notice that you can subtract one datetime from another, but you can
only add a timespan a datetime. I therefore created a timespan by
subtracting #1/1/1900 00:00:00# from the TimeWorked value. I then added
this timespan to a Total timespan. Unfortunately, this does not appear
to calculate correctly with example values:

TimeWorked
07:50
11:25
08:00
07:50
05:40

As I loop through these the values in tsTotal are:
tsTotal.Hours:tsTotal.Minutes
7:50
19:15
3:15 (Starts going wrong here?)
11:5
16:45
How can I add these values to get the Sum(TimeWorked)?

--
Cheers,

James Goodman



Nov 19 '05 #5
I must be going mad!

It was incrementing into days (e.g. 37:30 = 1d13h30m), but I am sure when I
looked at this property earlier it was displaying a crazy value. I think I
must have been looking at the TotalDays property.

Oh well, thanks anyway. :)

--
Cheers,

James Goodman
"James Goodman" <jamesATnorton-associates.co.ukREMOVE> wrote in message
news:el**************@TK2MSFTNGP14.phx.gbl...
I thought that, but when I added each timespan to my total timespan it went
kind of haywire.

I am not sure if it is because it is going beyond 24 hours & subsequently
trying to count in days?

--
Cheers,

James Goodman
"Kevin Spencer" <ke***@DIESPAMMERSDIEtakempis.com> wrote in message
news:uJ*************@TK2MSFTNGP12.phx.gbl...
Ah, well, in that case just add them all together as TimeSpans.

--
HTH,

Kevin Spencer
Microsoft MVP
.Net Developer
Sometimes you eat the elephant.
Sometimes the elephant eats you.

"James Goodman" <jamesATnorton-associates.co.ukREMOVE> wrote in message
news:OH*************@TK2MSFTNGP15.phx.gbl...
I have a SQL UDF which already gives the TimeWorked for each day, but I
want to add these up & display the total for the data in the grid (will
normally be for the selected week).

--
Cheers,

James Goodman
"Kevin Spencer" <ke***@DIESPAMMERSDIEtakempis.com> wrote in message
news:uv**************@tk2msftngp13.phx.gbl...
Hi James,

You don't want to add times. You want to subtract them. Subtracting the
Start Time from the End Time will result in a TimeSpan of the
difference between them Subtracting LunchDuration from that TimeSpan
will give you the net time worked.

--
HTH,

Kevin Spencer
Microsoft MVP
.Net Developer
Sometimes you eat the elephant.
Sometimes the elephant eats you.

"James Goodman" <jamesATnorton-associates.co.ukREMOVE> wrote in message
news:Oi*************@TK2MSFTNGP14.phx.gbl...
>I have modified the ASP.NET TimeTracker Starter Kit to include the
>ability for users to log working hours (Start Time, Finish Time, Lunch
>Duration). This is then presented to them in a grid & a TimeWorked
>column is calculated (in a UDF within the DB).
>
> I want to include a label in the footer of TimeWorked which will show
> the TotalTimeWorked in the format HH:mm (e.g. 37:30).
>
> All of these TimeWorked values are returned in the format #1/1/1900
> 7:30:00AM# which indicates a total of 07:30 for the day. This is
> formatted in the grid & displays as desired.
>
> I notice that you can subtract one datetime from another, but you can
> only add a timespan a datetime. I therefore created a timespan by
> subtracting #1/1/1900 00:00:00# from the TimeWorked value. I then
> added this timespan to a Total timespan. Unfortunately, this does not
> appear to calculate correctly with example values:
>
> TimeWorked
> 07:50
> 11:25
> 08:00
> 07:50
> 05:40
>
> As I loop through these the values in tsTotal are:
> tsTotal.Hours:tsTotal.Minutes
> 7:50
> 19:15
> 3:15 (Starts going wrong here?)
> 11:5
> 16:45
>
>
> How can I add these values to get the Sum(TimeWorked)?
>
>
>
> --
> Cheers,
>
> James Goodman
>



Nov 19 '05 #6
A TimeSpan has multiple components, just like a DateTime does. For example,
a Time Span of 6 hours, 12 minutes and 30 seconds has 6 hours, 12 minutes,
and 30 seconds in it. So if you reference YourTimeSpan.Minutes, the return
value will be 12, not 732 as you might expect. To get the total minutes
(732) out of it, you would refer to YourTimeSpan.TotalMinutes.

Does that help?

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Sometimes you eat the elephant.
Sometimes the elephant eats you.

"James Goodman" <jamesATnorton-associates.co.ukREMOVE> wrote in message
news:el**************@TK2MSFTNGP14.phx.gbl...
I thought that, but when I added each timespan to my total timespan it went
kind of haywire.

I am not sure if it is because it is going beyond 24 hours & subsequently
trying to count in days?

--
Cheers,

James Goodman
"Kevin Spencer" <ke***@DIESPAMMERSDIEtakempis.com> wrote in message
news:uJ*************@TK2MSFTNGP12.phx.gbl...
Ah, well, in that case just add them all together as TimeSpans.

--
HTH,

Kevin Spencer
Microsoft MVP
.Net Developer
Sometimes you eat the elephant.
Sometimes the elephant eats you.

"James Goodman" <jamesATnorton-associates.co.ukREMOVE> wrote in message
news:OH*************@TK2MSFTNGP15.phx.gbl...
I have a SQL UDF which already gives the TimeWorked for each day, but I
want to add these up & display the total for the data in the grid (will
normally be for the selected week).

--
Cheers,

James Goodman
"Kevin Spencer" <ke***@DIESPAMMERSDIEtakempis.com> wrote in message
news:uv**************@tk2msftngp13.phx.gbl...
Hi James,

You don't want to add times. You want to subtract them. Subtracting the
Start Time from the End Time will result in a TimeSpan of the
difference between them Subtracting LunchDuration from that TimeSpan
will give you the net time worked.

--
HTH,

Kevin Spencer
Microsoft MVP
.Net Developer
Sometimes you eat the elephant.
Sometimes the elephant eats you.

"James Goodman" <jamesATnorton-associates.co.ukREMOVE> wrote in message
news:Oi*************@TK2MSFTNGP14.phx.gbl...
>I have modified the ASP.NET TimeTracker Starter Kit to include the
>ability for users to log working hours (Start Time, Finish Time, Lunch
>Duration). This is then presented to them in a grid & a TimeWorked
>column is calculated (in a UDF within the DB).
>
> I want to include a label in the footer of TimeWorked which will show
> the TotalTimeWorked in the format HH:mm (e.g. 37:30).
>
> All of these TimeWorked values are returned in the format #1/1/1900
> 7:30:00AM# which indicates a total of 07:30 for the day. This is
> formatted in the grid & displays as desired.
>
> I notice that you can subtract one datetime from another, but you can
> only add a timespan a datetime. I therefore created a timespan by
> subtracting #1/1/1900 00:00:00# from the TimeWorked value. I then
> added this timespan to a Total timespan. Unfortunately, this does not
> appear to calculate correctly with example values:
>
> TimeWorked
> 07:50
> 11:25
> 08:00
> 07:50
> 05:40
>
> As I loop through these the values in tsTotal are:
> tsTotal.Hours:tsTotal.Minutes
> 7:50
> 19:15
> 3:15 (Starts going wrong here?)
> 11:5
> 16:45
>
>
> How can I add these values to get the Sum(TimeWorked)?
>
>
>
> --
> Cheers,
>
> James Goodman
>



Nov 19 '05 #7

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

Similar topics

5
by: Mark Fisher | last post by:
I have a Java desktop GUI application that the user can run multiple times. In order to keep one instance of the application distinct from another, I'd like to put the instance number of the...
6
by: Christian | last post by:
HI, I have a function that is used to constrain a query: Select COl1, Col2 From MyTable WHERE col1 = ... AND col2 = ... And MyFunction(col1) = ... My problem is that MyFunction is executed...
1
by: Anthony | last post by:
Here is a debate we have been having at work about the design of our timeclock database application. We have built an online timeclock system for companies to use to keep track of their employees...
10
by: Sunny K | last post by:
Hi guys, I have a field in my DB called EventDate as a DateTime field, therefore it holds both the date and time together like this: '2004-10-14 08:42:57.000'. I need to add together all the...
10
by: Mike | last post by:
I know this sounds strange but I am at a loss. I am calling a simple funtion that opens a connection to a SQL Server 2000 database and executes an Insert Statement. private void...
14
by: Steve McLellan | last post by:
Hi, Sorry to repost, but this is becoming aggravating, and causing me a lot of wasted time. I've got a reasonably large mixed C++ project, and after a number of builds (but not a constant...
87
by: John Rivers | last post by:
Hello everybody, I just wondered if anybody else has noticed this? It takes around 6 seconds to start debugging a very simple ASPX page with VS.NET whereas VB6 takes under 0.5 seconds, even...
4
by: viuxrluxvbbc | last post by:
Hi im trying to write a program that will read in numbers and display them in ascending order along with a count of how many times it repeats. i got the numerical order portion done but cant figure...
4
by: kwatch | last post by:
Hi, I have a question about os.times(). os.times() returns a tuple containing user time and system time, but it is not matched to the result of 'time' command. For example, os.times() reports...
2
by: hari | last post by:
Hi all, suppose a hex value is there(say 3B), this needs to be expanded. Suppose if this 3B(0011 1011) needs to be expanded by 3 times, then each bit should be expanded by 3 times(000000111111...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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...
0
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.