Shift Date

SzymonK

New member
Local time
Today, 00:13
Joined
Mar 29, 2022
Messages
14
I'm working on showing the shift date. The shift starts at 6 pm on one day and ends at 6 am on the next. What formula can I use so that the date does not change at midnight? I used something like this as the default value =DateAdd("d",-0.5,Date()), but it doesn't work for some reason. Please help Thank You
 
???Do you want the shift start date(and time) and the duration/length of the shift?
 
you can try for Default Value:

=Date()+#6:00:00 AM#
 
Do you want the shift start date(and time) and the duration/length of the shift?
Thank You jdraw!
The shift lasts 12 hours and covers two calendar dates. For example, today, it will be 29/03/2022 6 pm to 30/03/2022 at 6 am. After opening Access, the user has two options (buttons): Day shift (the same calendar day, so it's not a problem) and night shift. While opening and closing the night shift form is not a problem before 00., after midnight, if the user decides to close and reopen the form, a new record will appear. Dated on the calendar day, using an example, it will be 30.03, and I would like to record this as a Calendar date - 6 hr.
 
But Date -6 hrs would only be true for relogin after midnight.
Physically date changes at midnight, so if you record shiftStartDate and shift duration it seems both dayshift and nightshift are consistent. If logoff and relogin after midnight is the problem to be solved, then it seems you would still need to confirm the shift involved is a nightshift and it started "yesterday based on the relogin". Perhaps you could describe the issue involved in more detail with examples.
 
you can add code to the Form's Load event to change the date accordingly:

Code:
    With Me.dateFieldHere
        If TimeValue(Now) < #6:00:00 AM# Then
            .DefaultValue = "'" & DateAdd("d", -1, Date) & "'"
        Else
            .DefaultValue = "'" & Date & "'"
        End If
    End With
 
you can add code to the Form's Load event to change the date accordingly:

Code:
    With Me.dateFieldHere
        If TimeValue(Now) < #6:00:00 AM# Then
            .DefaultValue = "'" & DateAdd("d", -1, Date) & "'"
        Else
            .DefaultValue = "'" & Date & "'"
        End If
    End With
Hi arnelgp!!

Thank you very much!!!
Its works perfectly.

SzymonK
 

Users who are viewing this thread

Back
Top Bottom