Skip to Content

Solved: How do I create date variable with today’s date and time in MS SQL Server?

Question

I require a date and time variable to be created where the date component is the current date and the time component is 8:00AM.

Solution

DECLARE @myDTvariable smalldatetime = DATEADD(HOUR, 8, CAST(CAST(GETDATE() AS date) AS smalldatetime))
    Ads Blocker Image Powered by Code Help Pro

    It looks like you are using an adblocker.

    Ads keep our content free. Please consider supporting us by allowing ads on pupuweb.com