A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Database Design
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

I need to calculate in time, out time and lunch...



 
 
Thread Tools Display Modes
  #1  
Old May 4th, 2007, 04:01 PM posted to microsoft.public.access,microsoft.public.access.tablesdbdesign
Kelvin Beaton
external usenet poster
 
Posts: 231
Default I need to calculate in time, out time and lunch...

Hi there

I'm working on a data base to replace our Excel time sheet.
I need input on the data types for these fields.
Currently I have them setup this way.
StartTime (Date/Time, Medium Time) Input mask 99:00\ LL;0;_
Lunch (Date/Time, Short Time) Input mask 00:00;0;_
(input options are 0:15, 0:30, 0:45 etc.)
EndTime (Date/Time, Medium Time) Input mask 99:00\ LL;0;_

The Start and End Time come from a list that has a data type of (Date/Time,
Medium Time) Input mask 99:00\ LL;0;_

I want to be able to calculate the difference between the start and end
time, then subtract the lunch time.
So 8:00 AM to 5:00 PM and subtract a 1 hour lunch. Should come out to 8
hours worked...

Part of my question is, am I using the correct field/data types??

Any input would be appreciated!

Thanks

Kelvin


  #2  
Old May 4th, 2007, 04:08 PM posted to microsoft.public.access,microsoft.public.access.tablesdbdesign
Douglas J. Steele
external usenet poster
 
Posts: 9,313
Default I need to calculate in time, out time and lunch...

I'd recommend storing the Lunch as a Long Integer representing the number of
minutes.

Your total hours worked would then be:

DateDiff("n", [StartTime], [EndTime]) - [Lunch]/60

Note that you should be storing the Date as part of StartTime and EndTime.

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"Kelvin Beaton" kelvin at mccsa dot com wrote in message
...
Hi there

I'm working on a data base to replace our Excel time sheet.
I need input on the data types for these fields.
Currently I have them setup this way.
StartTime (Date/Time, Medium Time) Input mask 99:00\ LL;0;_
Lunch (Date/Time, Short Time) Input mask 00:00;0;_
(input options are 0:15, 0:30, 0:45 etc.)
EndTime (Date/Time, Medium Time) Input mask 99:00\ LL;0;_

The Start and End Time come from a list that has a data type of
(Date/Time, Medium Time) Input mask 99:00\ LL;0;_

I want to be able to calculate the difference between the start and end
time, then subtract the lunch time.
So 8:00 AM to 5:00 PM and subtract a 1 hour lunch. Should come out to 8
hours worked...

Part of my question is, am I using the correct field/data types??

Any input would be appreciated!

Thanks

Kelvin



  #3  
Old May 4th, 2007, 04:32 PM posted to microsoft.public.access,microsoft.public.access.tablesdbdesign
Kelvin Beaton
external usenet poster
 
Posts: 231
Default I need to calculate in time, out time and lunch...

Thanks Douglas for your reply!

When you say "you should be storing the Date as part of StartTime and
EndTime".
I'm storing the date in a separate field, but I suspect you mean in the same
field as the start and end times...
would you tell me a little more about what your mean?
In the drop down, I only want them to see the time, ie 8:00 AM not
05/04/2007 8:00 AM

Thanks

Kelvin


"Douglas J. Steele" wrote in message
...
I'd recommend storing the Lunch as a Long Integer representing the number
of minutes.

Your total hours worked would then be:

DateDiff("n", [StartTime], [EndTime]) - [Lunch]/60

Note that you should be storing the Date as part of StartTime and EndTime.

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"Kelvin Beaton" kelvin at mccsa dot com wrote in message
...
Hi there

I'm working on a data base to replace our Excel time sheet.
I need input on the data types for these fields.
Currently I have them setup this way.
StartTime (Date/Time, Medium Time) Input mask 99:00\ LL;0;_
Lunch (Date/Time, Short Time) Input mask 00:00;0;_
(input options are 0:15, 0:30, 0:45 etc.)
EndTime (Date/Time, Medium Time) Input mask 99:00\ LL;0;_

The Start and End Time come from a list that has a data type of
(Date/Time, Medium Time) Input mask 99:00\ LL;0;_

I want to be able to calculate the difference between the start and end
time, then subtract the lunch time.
So 8:00 AM to 5:00 PM and subtract a 1 hour lunch. Should come out to 8
hours worked...

Part of my question is, am I using the correct field/data types??

Any input would be appreciated!

Thanks

Kelvin





  #4  
Old May 4th, 2007, 05:53 PM posted to microsoft.public.access,microsoft.public.access.tablesdbdesign
Douglas J. Steele
external usenet poster
 
Posts: 9,313
Default I need to calculate in time, out time and lunch...

Store it as 05/04/2007 8:00 AM. Create a query that has two computed fields:
one using the DateValue function (so that it only returns 05/04/2007) and
one using the TimeValue function (so that it only returns 8:00 AM). Use the
query wherever you would otherwise have used the table.

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"Kelvin Beaton" kelvin at mccsa dot com wrote in message
...
Thanks Douglas for your reply!

When you say "you should be storing the Date as part of StartTime and
EndTime".
I'm storing the date in a separate field, but I suspect you mean in the
same field as the start and end times...
would you tell me a little more about what your mean?
In the drop down, I only want them to see the time, ie 8:00 AM not
05/04/2007 8:00 AM

Thanks

Kelvin


"Douglas J. Steele" wrote in message
...
I'd recommend storing the Lunch as a Long Integer representing the number
of minutes.

Your total hours worked would then be:

DateDiff("n", [StartTime], [EndTime]) - [Lunch]/60

Note that you should be storing the Date as part of StartTime and
EndTime.

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"Kelvin Beaton" kelvin at mccsa dot com wrote in message
...
Hi there

I'm working on a data base to replace our Excel time sheet.
I need input on the data types for these fields.
Currently I have them setup this way.
StartTime (Date/Time, Medium Time) Input mask 99:00\ LL;0;_
Lunch (Date/Time, Short Time) Input mask 00:00;0;_
(input options are 0:15, 0:30, 0:45 etc.)
EndTime (Date/Time, Medium Time) Input mask 99:00\ LL;0;_

The Start and End Time come from a list that has a data type of
(Date/Time, Medium Time) Input mask 99:00\ LL;0;_

I want to be able to calculate the difference between the start and end
time, then subtract the lunch time.
So 8:00 AM to 5:00 PM and subtract a 1 hour lunch. Should come out to 8
hours worked...

Part of my question is, am I using the correct field/data types??

Any input would be appreciated!

Thanks

Kelvin







  #5  
Old May 4th, 2007, 06:21 PM posted to microsoft.public.access,microsoft.public.access.tablesdbdesign
Kelvin Beaton
external usenet poster
 
Posts: 231
Default I need to calculate in time, out time and lunch...

thanks, I'll look at that idea....

This part seems to work fine,
Expr1: DateDiff("n",[StartTime],[EndTime])

Expr1: DateDiff("n",[StartTime],[EndTime])-[Lunchtime]/60
It returns nothing when I leave the "-[Lunchtime]/60" part on...

I tried these options too. non worked
Expr1: (DateDiff("n",[StartTime],[EndTime]))-([Lunchtime]/60)
Expr1: ([lunchtime]/60)-(DateDiff("n",[StartTime],[EndTime]))

Kelvin



"Douglas J. Steele" wrote in message
...
Store it as 05/04/2007 8:00 AM. Create a query that has two computed
fields: one using the DateValue function (so that it only returns
05/04/2007) and one using the TimeValue function (so that it only returns
8:00 AM). Use the query wherever you would otherwise have used the table.

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"Kelvin Beaton" kelvin at mccsa dot com wrote in message
...
Thanks Douglas for your reply!

When you say "you should be storing the Date as part of StartTime and
EndTime".
I'm storing the date in a separate field, but I suspect you mean in the
same field as the start and end times...
would you tell me a little more about what your mean?
In the drop down, I only want them to see the time, ie 8:00 AM not
05/04/2007 8:00 AM

Thanks

Kelvin


"Douglas J. Steele" wrote in message
...
I'd recommend storing the Lunch as a Long Integer representing the
number of minutes.

Your total hours worked would then be:

DateDiff("n", [StartTime], [EndTime]) - [Lunch]/60

Note that you should be storing the Date as part of StartTime and
EndTime.

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"Kelvin Beaton" kelvin at mccsa dot com wrote in message
...
Hi there

I'm working on a data base to replace our Excel time sheet.
I need input on the data types for these fields.
Currently I have them setup this way.
StartTime (Date/Time, Medium Time) Input mask 99:00\ LL;0;_
Lunch (Date/Time, Short Time) Input mask 00:00;0;_
(input options are 0:15, 0:30, 0:45 etc.)
EndTime (Date/Time, Medium Time) Input mask 99:00\ LL;0;_

The Start and End Time come from a list that has a data type of
(Date/Time, Medium Time) Input mask 99:00\ LL;0;_

I want to be able to calculate the difference between the start and end
time, then subtract the lunch time.
So 8:00 AM to 5:00 PM and subtract a 1 hour lunch. Should come out to 8
hours worked...

Part of my question is, am I using the correct field/data types??

Any input would be appreciated!

Thanks

Kelvin









  #6  
Old May 4th, 2007, 08:31 PM posted to microsoft.public.access,microsoft.public.access.tablesdbdesign
Douglas J. Steele
external usenet poster
 
Posts: 9,313
Default I need to calculate in time, out time and lunch...

Does Lunchtime have a value, or is it Null?

If it's possible that there's no value for Lunchtime, use

Expr1: DateDiff("n",[StartTime],[EndTime])-Nz([Lunchtime],0)/60


--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"Kelvin Beaton" kelvin at mccsa dot com wrote in message
...
thanks, I'll look at that idea....

This part seems to work fine,
Expr1: DateDiff("n",[StartTime],[EndTime])

Expr1: DateDiff("n",[StartTime],[EndTime])-[Lunchtime]/60
It returns nothing when I leave the "-[Lunchtime]/60" part on...

I tried these options too. non worked
Expr1: (DateDiff("n",[StartTime],[EndTime]))-([Lunchtime]/60)
Expr1: ([lunchtime]/60)-(DateDiff("n",[StartTime],[EndTime]))

Kelvin



"Douglas J. Steele" wrote in message
...
Store it as 05/04/2007 8:00 AM. Create a query that has two computed
fields: one using the DateValue function (so that it only returns
05/04/2007) and one using the TimeValue function (so that it only returns
8:00 AM). Use the query wherever you would otherwise have used the table.

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"Kelvin Beaton" kelvin at mccsa dot com wrote in message
...
Thanks Douglas for your reply!

When you say "you should be storing the Date as part of StartTime and
EndTime".
I'm storing the date in a separate field, but I suspect you mean in the
same field as the start and end times...
would you tell me a little more about what your mean?
In the drop down, I only want them to see the time, ie 8:00 AM not
05/04/2007 8:00 AM

Thanks

Kelvin


"Douglas J. Steele" wrote in message
...
I'd recommend storing the Lunch as a Long Integer representing the
number of minutes.

Your total hours worked would then be:

DateDiff("n", [StartTime], [EndTime]) - [Lunch]/60

Note that you should be storing the Date as part of StartTime and
EndTime.

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"Kelvin Beaton" kelvin at mccsa dot com wrote in message
...
Hi there

I'm working on a data base to replace our Excel time sheet.
I need input on the data types for these fields.
Currently I have them setup this way.
StartTime (Date/Time, Medium Time) Input mask 99:00\ LL;0;_
Lunch (Date/Time, Short Time) Input mask 00:00;0;_
(input options are 0:15, 0:30, 0:45 etc.)
EndTime (Date/Time, Medium Time) Input mask 99:00\ LL;0;_

The Start and End Time come from a list that has a data type of
(Date/Time, Medium Time) Input mask 99:00\ LL;0;_

I want to be able to calculate the difference between the start and
end time, then subtract the lunch time.
So 8:00 AM to 5:00 PM and subtract a 1 hour lunch. Should come out to
8 hours worked...

Part of my question is, am I using the correct field/data types??

Any input would be appreciated!

Thanks

Kelvin











  #7  
Old May 4th, 2007, 08:54 PM posted to microsoft.public.access,microsoft.public.access.tablesdbdesign
Kelvin Beaton
external usenet poster
 
Posts: 231
Default I need to calculate in time, out time and lunch...

That works great!
Yes there was no lunch time entered...

Thanks again for your time!

Kelvin


"Douglas J. Steele" wrote in message
...
Does Lunchtime have a value, or is it Null?

If it's possible that there's no value for Lunchtime, use

Expr1: DateDiff("n",[StartTime],[EndTime])-Nz([Lunchtime],0)/60


--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"Kelvin Beaton" kelvin at mccsa dot com wrote in message
...
thanks, I'll look at that idea....

This part seems to work fine,
Expr1: DateDiff("n",[StartTime],[EndTime])

Expr1: DateDiff("n",[StartTime],[EndTime])-[Lunchtime]/60
It returns nothing when I leave the "-[Lunchtime]/60" part on...

I tried these options too. non worked
Expr1: (DateDiff("n",[StartTime],[EndTime]))-([Lunchtime]/60)
Expr1: ([lunchtime]/60)-(DateDiff("n",[StartTime],[EndTime]))

Kelvin



"Douglas J. Steele" wrote in message
...
Store it as 05/04/2007 8:00 AM. Create a query that has two computed
fields: one using the DateValue function (so that it only returns
05/04/2007) and one using the TimeValue function (so that it only
returns 8:00 AM). Use the query wherever you would otherwise have used
the table.

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"Kelvin Beaton" kelvin at mccsa dot com wrote in message
...
Thanks Douglas for your reply!

When you say "you should be storing the Date as part of StartTime and
EndTime".
I'm storing the date in a separate field, but I suspect you mean in the
same field as the start and end times...
would you tell me a little more about what your mean?
In the drop down, I only want them to see the time, ie 8:00 AM not
05/04/2007 8:00 AM

Thanks

Kelvin


"Douglas J. Steele" wrote in
message ...
I'd recommend storing the Lunch as a Long Integer representing the
number of minutes.

Your total hours worked would then be:

DateDiff("n", [StartTime], [EndTime]) - [Lunch]/60

Note that you should be storing the Date as part of StartTime and
EndTime.

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"Kelvin Beaton" kelvin at mccsa dot com wrote in message
...
Hi there

I'm working on a data base to replace our Excel time sheet.
I need input on the data types for these fields.
Currently I have them setup this way.
StartTime (Date/Time, Medium Time) Input mask 99:00\ LL;0;_
Lunch (Date/Time, Short Time) Input mask 00:00;0;_
(input options are 0:15, 0:30, 0:45 etc.)
EndTime (Date/Time, Medium Time) Input mask 99:00\ LL;0;_

The Start and End Time come from a list that has a data type of
(Date/Time, Medium Time) Input mask 99:00\ LL;0;_

I want to be able to calculate the difference between the start and
end time, then subtract the lunch time.
So 8:00 AM to 5:00 PM and subtract a 1 hour lunch. Should come out to
8 hours worked...

Part of my question is, am I using the correct field/data types??

Any input would be appreciated!

Thanks

Kelvin













  #8  
Old May 4th, 2007, 09:18 PM posted to microsoft.public.access,microsoft.public.access.tablesdbdesign
Kelvin Beaton
external usenet poster
 
Posts: 231
Default I need to calculate in time, out time and lunch...

Well I thought is was, but...

I did have to modify it some...
TimeWorked: (DateDiff("n",[StartTime],[EndTime])-Nz([Lunchtime],0))/60

Thanks

Kelvin

"Douglas J. Steele" wrote in message
...
Does Lunchtime have a value, or is it Null?

If it's possible that there's no value for Lunchtime, use

Expr1: DateDiff("n",[StartTime],[EndTime])-Nz([Lunchtime],0)/60


--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"Kelvin Beaton" kelvin at mccsa dot com wrote in message
...
thanks, I'll look at that idea....

This part seems to work fine,
Expr1: DateDiff("n",[StartTime],[EndTime])

Expr1: DateDiff("n",[StartTime],[EndTime])-[Lunchtime]/60
It returns nothing when I leave the "-[Lunchtime]/60" part on...

I tried these options too. non worked
Expr1: (DateDiff("n",[StartTime],[EndTime]))-([Lunchtime]/60)
Expr1: ([lunchtime]/60)-(DateDiff("n",[StartTime],[EndTime]))

Kelvin



"Douglas J. Steele" wrote in message
...
Store it as 05/04/2007 8:00 AM. Create a query that has two computed
fields: one using the DateValue function (so that it only returns
05/04/2007) and one using the TimeValue function (so that it only
returns 8:00 AM). Use the query wherever you would otherwise have used
the table.

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"Kelvin Beaton" kelvin at mccsa dot com wrote in message
...
Thanks Douglas for your reply!

When you say "you should be storing the Date as part of StartTime and
EndTime".
I'm storing the date in a separate field, but I suspect you mean in the
same field as the start and end times...
would you tell me a little more about what your mean?
In the drop down, I only want them to see the time, ie 8:00 AM not
05/04/2007 8:00 AM

Thanks

Kelvin


"Douglas J. Steele" wrote in
message ...
I'd recommend storing the Lunch as a Long Integer representing the
number of minutes.

Your total hours worked would then be:

DateDiff("n", [StartTime], [EndTime]) - [Lunch]/60

Note that you should be storing the Date as part of StartTime and
EndTime.

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"Kelvin Beaton" kelvin at mccsa dot com wrote in message
...
Hi there

I'm working on a data base to replace our Excel time sheet.
I need input on the data types for these fields.
Currently I have them setup this way.
StartTime (Date/Time, Medium Time) Input mask 99:00\ LL;0;_
Lunch (Date/Time, Short Time) Input mask 00:00;0;_
(input options are 0:15, 0:30, 0:45 etc.)
EndTime (Date/Time, Medium Time) Input mask 99:00\ LL;0;_

The Start and End Time come from a list that has a data type of
(Date/Time, Medium Time) Input mask 99:00\ LL;0;_

I want to be able to calculate the difference between the start and
end time, then subtract the lunch time.
So 8:00 AM to 5:00 PM and subtract a 1 hour lunch. Should come out to
8 hours worked...

Part of my question is, am I using the correct field/data types??

Any input would be appreciated!

Thanks

Kelvin













  #9  
Old May 4th, 2007, 09:44 PM posted to microsoft.public.access,microsoft.public.access.tablesdbdesign
Douglas J. Steele
external usenet poster
 
Posts: 9,313
Default I need to calculate in time, out time and lunch...

Sorry, that was a typo on my part: I'd originally meant to use "h" in the
DateDiff function to calculate hours, but using "n" for minutes is more
accurate.

Glad you got it working.

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no private e-mails, please)


"Kelvin Beaton" kelvin at mccsa dot com wrote in message
...
Well I thought is was, but...

I did have to modify it some...
TimeWorked: (DateDiff("n",[StartTime],[EndTime])-Nz([Lunchtime],0))/60

Thanks

Kelvin

"Douglas J. Steele" wrote in message
...
Does Lunchtime have a value, or is it Null?

If it's possible that there's no value for Lunchtime, use

Expr1: DateDiff("n",[StartTime],[EndTime])-Nz([Lunchtime],0)/60


--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"Kelvin Beaton" kelvin at mccsa dot com wrote in message
...
thanks, I'll look at that idea....

This part seems to work fine,
Expr1: DateDiff("n",[StartTime],[EndTime])

Expr1: DateDiff("n",[StartTime],[EndTime])-[Lunchtime]/60
It returns nothing when I leave the "-[Lunchtime]/60" part on...

I tried these options too. non worked
Expr1: (DateDiff("n",[StartTime],[EndTime]))-([Lunchtime]/60)
Expr1: ([lunchtime]/60)-(DateDiff("n",[StartTime],[EndTime]))

Kelvin



"Douglas J. Steele" wrote in message
...
Store it as 05/04/2007 8:00 AM. Create a query that has two computed
fields: one using the DateValue function (so that it only returns
05/04/2007) and one using the TimeValue function (so that it only
returns 8:00 AM). Use the query wherever you would otherwise have used
the table.

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"Kelvin Beaton" kelvin at mccsa dot com wrote in message
...
Thanks Douglas for your reply!

When you say "you should be storing the Date as part of StartTime and
EndTime".
I'm storing the date in a separate field, but I suspect you mean in
the same field as the start and end times...
would you tell me a little more about what your mean?
In the drop down, I only want them to see the time, ie 8:00 AM not
05/04/2007 8:00 AM

Thanks

Kelvin


"Douglas J. Steele" wrote in
message ...
I'd recommend storing the Lunch as a Long Integer representing the
number of minutes.

Your total hours worked would then be:

DateDiff("n", [StartTime], [EndTime]) - [Lunch]/60

Note that you should be storing the Date as part of StartTime and
EndTime.

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"Kelvin Beaton" kelvin at mccsa dot com wrote in message
...
Hi there

I'm working on a data base to replace our Excel time sheet.
I need input on the data types for these fields.
Currently I have them setup this way.
StartTime (Date/Time, Medium Time) Input mask 99:00\ LL;0;_
Lunch (Date/Time, Short Time) Input mask 00:00;0;_
(input options are 0:15, 0:30, 0:45 etc.)
EndTime (Date/Time, Medium Time) Input mask 99:00\ LL;0;_

The Start and End Time come from a list that has a data type of
(Date/Time, Medium Time) Input mask 99:00\ LL;0;_

I want to be able to calculate the difference between the start and
end time, then subtract the lunch time.
So 8:00 AM to 5:00 PM and subtract a 1 hour lunch. Should come out
to 8 hours worked...

Part of my question is, am I using the correct field/data types??

Any input would be appreciated!

Thanks

Kelvin















  #10  
Old May 6th, 2007, 07:10 PM posted to microsoft.public.access,microsoft.public.access.queries,microsoft.public.access.tablesdbdesign
Kelvin Beaton[_2_]
external usenet poster
 
Posts: 7
Default I need to calculate in time, out time and lunch...

Hi Douglas

Thanks for your help so far...!

I need to add on more time field to this.

TimeWorked: (DateDiff("n",[StartTime],[EndTime])-Nz([Lunchtime],0))/60

I need to add "OtherHours" to this.
I'm storing "OtherHours as LongInteger
This field can have a zero value.

I tried this a number of different ways with no luck...
+Nz([OtherHours])

Your help is appreciated!

Kelvin


"Douglas J. Steele" wrote in message
...
Sorry, that was a typo on my part: I'd originally meant to use "h" in the
DateDiff function to calculate hours, but using "n" for minutes is more
accurate.

Glad you got it working.

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no private e-mails, please)


"Kelvin Beaton" kelvin at mccsa dot com wrote in message
...
Well I thought is was, but...

I did have to modify it some...
TimeWorked: (DateDiff("n",[StartTime],[EndTime])-Nz([Lunchtime],0))/60

Thanks

Kelvin

"Douglas J. Steele" wrote in message
...
Does Lunchtime have a value, or is it Null?

If it's possible that there's no value for Lunchtime, use

Expr1: DateDiff("n",[StartTime],[EndTime])-Nz([Lunchtime],0)/60


--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"Kelvin Beaton" kelvin at mccsa dot com wrote in message
...
thanks, I'll look at that idea....

This part seems to work fine,
Expr1: DateDiff("n",[StartTime],[EndTime])

Expr1: DateDiff("n",[StartTime],[EndTime])-[Lunchtime]/60
It returns nothing when I leave the "-[Lunchtime]/60" part on...

I tried these options too. non worked
Expr1: (DateDiff("n",[StartTime],[EndTime]))-([Lunchtime]/60)
Expr1: ([lunchtime]/60)-(DateDiff("n",[StartTime],[EndTime]))

Kelvin



"Douglas J. Steele" wrote in
message ...
Store it as 05/04/2007 8:00 AM. Create a query that has two computed
fields: one using the DateValue function (so that it only returns
05/04/2007) and one using the TimeValue function (so that it only
returns 8:00 AM). Use the query wherever you would otherwise have used
the table.

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"Kelvin Beaton" kelvin at mccsa dot com wrote in message
...
Thanks Douglas for your reply!

When you say "you should be storing the Date as part of StartTime and
EndTime".
I'm storing the date in a separate field, but I suspect you mean in
the same field as the start and end times...
would you tell me a little more about what your mean?
In the drop down, I only want them to see the time, ie 8:00 AM not
05/04/2007 8:00 AM

Thanks

Kelvin


"Douglas J. Steele" wrote in
message ...
I'd recommend storing the Lunch as a Long Integer representing the
number of minutes.

Your total hours worked would then be:

DateDiff("n", [StartTime], [EndTime]) - [Lunch]/60

Note that you should be storing the Date as part of StartTime and
EndTime.

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"Kelvin Beaton" kelvin at mccsa dot com wrote in message
...
Hi there

I'm working on a data base to replace our Excel time sheet.
I need input on the data types for these fields.
Currently I have them setup this way.
StartTime (Date/Time, Medium Time) Input mask 99:00\ LL;0;_
Lunch (Date/Time, Short Time) Input mask 00:00;0;_
(input options are 0:15, 0:30, 0:45 etc.)
EndTime (Date/Time, Medium Time) Input mask 99:00\ LL;0;_

The Start and End Time come from a list that has a data type of
(Date/Time, Medium Time) Input mask 99:00\ LL;0;_

I want to be able to calculate the difference between the start and
end time, then subtract the lunch time.
So 8:00 AM to 5:00 PM and subtract a 1 hour lunch. Should come out
to 8 hours worked...

Part of my question is, am I using the correct field/data types??

Any input would be appreciated!

Thanks

Kelvin

















 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 06:26 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.