Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Time Calculation

Author  Topic 

Hockey77
Starting Member

1 Post

Posted - 2008-09-17 : 23:30:32
New to this forum.

Would like to create a function that would do the following:
1. Take a datetime (from GetDate() function) which represent logging time of an activity.
2. Because of shift designations in our business, I need to subtract one hour from the recording of the GetDate Time element.

SQL Code Testing:

select DateL, ShiftL, convert(varchar, DateL, 101)as stgDateL,
convert(varchar, DateL, 108)as DateLTime,
convert(varchar, (DateL-.04166), 108)as newDateLTime
from dbo.tblLoad
where DateL is not Null

This calculation gets the 1 hour reduction.

Now have to assign proper shift coding based upon our designated hours.

Let's assume 7:00:00 is the start of 1st Shift.

I'd like to do comparison of the newDateLTime with 7:00:00 to assign proper shift designation.

Any suggestions would be appreciated.

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2008-09-18 : 04:15:56
moved from script library.

_______________________________________________
Causing trouble since 1980
Blog: http://weblogs.sqlteam.com/mladenp
Speed up SSMS development: www.ssmstoolspack.com <- version 1.0 out!
Go to Top of Page
   

- Advertisement -