converting datetime in sqlserver like yyyy-mm-dd hh:mi:ss to yyyy-mm-dd 23:59:59

Hi I want to convert the date time like below 2015-05-12 23:59:59. The hours and secs and should come like 12:59:59 this.

Ex: I want to convert today's date like below 2015-08-17 23:59:59.

Edited

for GETDATE() in sql server I will get the datetime like this 2015-08-17 17:10:54.080 this one I want to convert into 2015-08-17 23:59:59.080

Answers


Seems this question is not about formatting. So here is a solution to get last timestamps of the day:

To get the last minute of the day:

SELECT dateadd(d, datediff(d, 0, getdate()), cast('23:59:59' as datetime))

Returns:

2015-08-17 23:59:59.000

To get the last possible timestamp of the day:

SELECT dateadd(d, datediff(d, 0, getdate()), cast('23:59:59:997' as datetime))
2015-08-17 23:59:59.997

Need Your Help

Overflow Menu doesn't work on Appcompat

android android-studio android-actionbar appcompat overflow-menu

I have just moved from Eclipse to Android Studio, and I am using the Appcompat library because it comes by default in Android Studio and it is hard to deactivate it.

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.