Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

getdate tsql question

Tags:

tsql

How do I write TSQL that it calculates the following:

  1. the current date and mid night such as 2010-12-01 00:00:00.000
  2. the current date and 6pm such as 2010-12-01 18:00:00.000

Thanks..

like image 915
dotnet-practitioner Avatar asked Feb 25 '23 17:02

dotnet-practitioner


1 Answers

You can try something like the following

SELECT DATEADD(dd, DATEDIFF(dd, 0, GETDATE()), 0) AS DateNoTime, 
    DATEADD(hh, 18, DATEADD(dd, DATEDIFF(dd, 0, GETDATE()), 0)) AS DateNewTime
like image 169
bobs Avatar answered Mar 06 '23 00:03

bobs