Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Development Tools
 ASP.NET
 Convert Date to 12/24 hours format

Author  Topic 

naveengopinathasari
Yak Posting Veteran

60 Posts

Posted - 2011-07-22 : 03:13:28
I need to convert Time in 12 hrs and 24 hrs format.

I have a column Datatype DATETIME
which will have date and Time
i need to convert
case 1 in 24hrs format
case 2 in 12 hrs format

Example
2010-12-21 01:14:43.4730000

This has to be displayed in
case 1
2010-12-21 01:14:43.4730000'

case 2
2010-12-21 13:14:43.4730000'



Lets unLearn

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2011-07-22 : 04:18:03
formatting of the date / time should be done at the front end application not in SQL Query.


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

elwoos
Master Smack Fu Yak Hacker

2052 Posts

Posted - 2011-07-22 : 09:23:49
Khtan is correct. As you have posted in the ASP.NET section you may find what you want here - http://msdn.microsoft.com/en-us/library/zdtaw1bw.aspx

-----------

What color do you want that database?
Go to Top of Page

3magic
Starting Member

14 Posts

Posted - 2011-08-10 : 01:13:47
SELECT convert(varchar, getdate(), 100) – mon dd yyyy hh:mmAM (or PM)

– Oct 2 2008 11:01AM
Go to Top of Page
   

- Advertisement -