|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Specifying the duration of a day
Hi there,
Can someone let me know as to how I can specify the duration (beginning and end ) of a day in Access? I want Access to calculate values based upon a day that runs from 7 am to 7 am, instead of midnight to midnight. Thanks A |
|
#2
|
||||
|
||||
|
In Access when you just specify the date it always represent the beginning of the day i.e. If today is 10th feb 2004 then it repsents 02/10/2004 00.00 AM. So if you use the following command dateadd("s","25200",Date) will give you 02/10/2004 07.00:00 AM. (s represent seconds and 25200 is 7 hrs * 60 min * 60 seconds).
In queries you can use as follows select Datefield from table where datefield between dateadd("s","25200",BeginDate) and dateadd("s","25200",EndDate)
__________________
V.Subramanian |
|
#3
|
|||
|
|||
|
|
|
#4
|
|||
|
|||
|
system wide date change?
thanks subra and baxter.
however, what i want access to do is: consider that the beginning and end of every day occurs at 7 am and 6:59 am, as opposed to midnight to midnight. i.e. 10th feb begins at 7 am and ends at 6.59 am on the following day. i guess what i am looking for is a systemwide thingie. |
|
#5
|
|||
|
|||
|
As far as I know that isn't possible.
S- |
|
#6
|
||||
|
||||
|
Yes. Sbaxter is perfectly right. But I dont understand the need for system date side maintenance. As long as you can get report, the way you want, from the data using the techniques mentioned in previous replies where comes the necessity for changing system date. If you can specify your requirement more elaborately probably we can give a suitable suggestion.
|
|
#7
|
||||
|
||||
|
Just after a second thought I think I have understood your problem. Your requirement, I feel is, whatever be the time punched by your staff if it falls between 9th feb 2004 7.00 am and 10th feb 2004 6.59 am the worked date should go into table as 9th feb 2004. This requirement normally arises in 3 shift organizations (24X7). If my above explanation is correct
use the following function before updating the table. My suggestion is to have 2 fields to store both punched time and workeddate into the table for future clarification. If i am not clear explain your situation. Function WorkedDate(DateTimePunched As Date) As Date Dim DayBeginTime as Date Dim PunchedDate as Date Dim PreviousDate as Date DayBeginTime = Format(DateTimePunched, "short date") DayBeginTime=DateAdd("s", "25200", DayBeginTime) PunchedDate=Format(DateTimePunched, "short date") PreviousDate = PunchedDate-1 If DateTimePunched < DayBeginTime Then WorkedDate = PreviousDate Else WorkedDate = PunchedDate End If End Function |
![]() |
| Viewing: ASP Free Forums > Database > Microsoft Access Help > Specifying the duration of a day |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|