March 17, 2006 at 1:18 pm
We currently have 3 shifts working everyday
5 AM - 12 PM, 1 PM - 8 PM, 9 PM - 4 AM
I currently have a transaction datetime and need to convert it to two fields
Shift Date work done, and Hour. My dilemna is how to do this. In MSACCESS you can do this but it does not work in SQL
Work Date: DateSerial(Year(Pack_Production_Transaction_datetime-(5/24)),Month(Pack_Production_Transaction_datetime-(5/24)),Day(Pack_Production_Transaction_datetime-(5/24)))
Time: (Pack_Production_Transaction_datetime-5/24)-Int(Pack_Production_Transaction_datetime-5/24)
So basically if the datetime comes over like this
'3/5/2006 4:27:45 AM' I need it to read like this 3/4/2006 23:27:45 and when
it looks like this
'3/5/2006 5:27:45 AM' I need it to read like this 3/5/2006 0:27:45 and so on
Any help is appreciated
March 18, 2006 at 7:45 pm
Basically, your saying you want to subtract 5 hours from anygiven datetime... this'll do just that...
SELECT DATEADD(hh,-5,somedatetime)
--Jeff Moden
Change is inevitable... Change for the better is not.
March 20, 2006 at 8:03 am
Ya know I guess I was making a mountain out of a mole hill. Yes that will work. I appreciate you helping me with that
March 21, 2006 at 6:50 pm
Not a problem... wasn't sure that's what you wanted but glad to help...
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply