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
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Date and Time Format

Author  Topic 

kaarthik
Starting Member

1 Post

Posted - 2011-04-23 : 03:31:26
i need to bind the date and time as 04/23/2011 1:00pm plz provide the sql standard code for this fomar or give ur suggesstion


thanks in advance

t.k.karthi

sunitabeck
Master Smack Fu Yak Hacker

5155 Posts

Posted - 2011-04-23 : 06:59:40
Standard formatting codes for date and time are listed on this page: http://msdn.microsoft.com/en-us/library/ms187928.aspx. If none of those meet your exact requirement, you may need to compose your string for example like this:
convert(varchar(32),yourDateCol,101) + ' ' + convert(varchar(32), youDateCol,108);


You mentioned "bind the date". Can you explain more? Typically, if you need to bind the date that comes from the database to a UI control, you don't need to do the formatting in SQL. The control should/would allow you to do the formatting.
Go to Top of Page

lionofdezert
Aged Yak Warrior

885 Posts

Posted - 2011-04-25 : 03:47:57
SQL Server: 20 Most Commonly Used DateTime Formats
http://connectsql.blogspot.com/2011/02/sql-server-20-most-commonly-used.html

Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2011-04-25 : 04:47:47
If you want to show formatted dates in front end application, do formation there

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -