Access table set start of day and end of day to my schedule

Tcurtis

Board Regular
Joined
Aug 15, 2009
Messages
149
Good Afternoon,
I am trying to convert a Date/Time in a table to give me a Day or Night shift designation.
I have a column in a table that has a Date/Time Stamp with AM and PM and need to know if the event listed on the date is during the night shift or the day shift.
Day shift begins at 7:00:00 AM and ends at 6:59:59 PM. Night shift begins at 7:00:00 PM and ends at 6:59:59 AM.
I would like to have a query or VBA update my table with a new column that gives me the correct designation of D or N according to the Start and Stop times of each shift. Below is how my column is laid out.

Thanks


Posting_Date
1/18/2023 8:04:21 AM
1/18/2023 8:04:21 AM
1/18/2023 11:50:46 AM
1/17/2023 10:59:03 AM
1/18/2023 11:51:56 AM
1/18/2023 11:28:46 AM
1/18/2023 11:00:17 AM
1/18/2023 11:04:00 AM
1/17/2023 11:10:03 AM
1/18/2023 12:29:08 PM
1/17/2023 10:58:02 AM
1/18/2023 11:02:33 AM
1/17/2023 1:06:22 PM
1/18/2023 11:22:52 AM
1/18/2023 12:34:37 PM
1/17/2023 3:46:37 PM
1/17/2023 3:45:42 PM
1/17/2023 10:58:30 AM
1/18/2023 11:09:01 AM
1/18/2023 10:37:40 AM
1/18/2023 11:20:53 AM
1/18/2023 11:50:46 AM
1/17/2023 1:11:55 PM
1/17/2023 1:08:15 PM
1/17/2023 3:42:19 PM
1/17/2023 2:23:28 PM
1/17/2023 2:14:39 PM
1/17/2023 11:12:50 AM
1/18/2023 11:09:01 AM
1/17/2023 3:46:04 PM
1/17/2023 1:11:55 PM
1/18/2023 11:22:52 AM
1/17/2023 2:23:28 PM
1/17/2023 2:23:28 PM
1/17/2023 3:48:50 PM
1/17/2023 3:49:44 PM
1/17/2023 3:49:44 PM
1/18/2023 11:14:29 AM
1/18/2023 11:36:08 AM
1/18/2023 11:20:53 AM
1/18/2023 11:14:29 AM
1/18/2023 11:14:29 AM
1/18/2023 12:27:32 PM
1/18/2023 10:57:19 AM
1/18/2023 11:20:53 AM
1/18/2023 11:50:46 AM
1/18/2023 12:20:24 PM
1/18/2023 11:36:08 AM
1/18/2023 11:01:38 AM
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
Created a new field called Time with the following expression first

Time: TimeValue([Posting_Date])

Try this SQL statement in a query

SQL:
SELECT Times.Posting_Date, TimeValue([Posting_Date]) AS [Time], IIf(TimeValue([Time])>#12/30/1899 18:59:59# Or TimeValue([Time])<#12/30/1899 7:0:0#,"night","day") AS [Day/Night]
FROM Times;

Change Times (my table name) to whatever your table name is
 
Upvote 0
Solution

Forum statistics

Threads
1,223,893
Messages
6,175,240
Members
452,621
Latest member
Laura_PinksBTHFT

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top