Set default time in SQL Server

  • [?]Hi guys

    I'm writing a Stored Procedure, on SQL Server 2005. I need to set a default time for the clock system, The clock in/out system works like this: When you clock in = 0, Clock Out = 1. So other employees they forget to clock out, we want to set a default time that when the employee didn't clock out then clock out time is 4:00PM.

    I've been struggling I don't know how to tackle it.

    Please help.

    Ndi

  • You could always iterate through your timesheet table at COB and update the records accordingly, i.e.

    UPDATE MyTimeSheetTable WITH(ROWLOCK)

    SET ClockOut = 1, MyDateColumn = CAST((CONVERT(varchar(10),getdate(),101) + ' 16:00:01') as datetime)

    FROM MyTimeSheetTable

    WHERE MyDateColumn IS NULL

    Not sure if I'm understanding all of your requirements. Hope this helps 🙂

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply