• lsalih (10/11/2013)


    Hi -

    What is a best way to set a field value to today date and time would be a always set to 4:00:00? Please advice

    Loads of ways. What have you tried? Here's a couple off the top of my head.

    SELECT CAST(CAST(GETDATE() AS DATE) AS DATETIME)+CAST('04:00:00' AS TIME) AS [Option 1],

    DATEADD(dd, DATEDIFF(dd, '2000-01-01 00:00:00', GETDATE()), '2000-01-01 04:00:00') AS [Option 2];


    Forever trying to learn
    My blog - http://www.cadavre.co.uk/
    For better, quicker answers on T-SQL questions, click on the following...http://www.sqlservercentral.com/articles/Best+Practices/61537/
    For better, quicker answers on SQL Server performance related questions, click on the following...http://www.sqlservercentral.com/articles/SQLServerCentral/66909/