getdate tsql question

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..

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

  1. dateadd(dd,datediff(dd,0, getDate()),0)
  2. dateadd(hh,18 + (24 *datediff(dd,0, getDate())),0)

Need Your Help

How to dispose a UserControl instance hosted by CWinFormsControl in MFC

.net visual-c++ mfc c++-cli

In My MFC project, I used CWinFormsControl to host a .Net UserControl.

Can't find my source code after exception thrown

c++ debugging visual-studio-2015

I have been working on a single thread C++ program using visual studio. I have been running the "debug" version and normally If I come across some kind of crash the debugger helpfully points me to ...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.