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 2008 Forums
 Transact-SQL (2008)
 How to format date in (23 March 2009 10:30 pm) in

Author  Topic 

anup_phansa
Starting Member

6 Posts

Posted - 2009-09-08 : 01:15:14
How to format date in (23 March 2009 10:30 pm) in select statement
Hi All

My field data type is datetime , actually data save in given below format

2009-06-12 12:14:42.080
2009-06-12 12:21:36.750
2009-06-12 12:20:12.627


Regards
Anup

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2009-09-08 : 01:18:03
please perform the required date formatting in your front end application.

If you have to do it in SQL, check out CAST & CONVERT in Books On Line


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

Go to Top of Page

anup_phansa
Starting Member

6 Posts

Posted - 2009-09-08 : 02:05:37
Hi

Thanks for your reply

i have try many option of convert function , but does not get exact output ,
please give proper option for convert function that give exact output

Regards
anup
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2009-09-08 : 03:05:17
quote:
Originally posted by anup_phansa

How to format date in (23 March 2009 10:30 pm) in select statement
Hi All

My field data type is datetime , actually data save in given below format

2009-06-12 12:14:42.080
2009-06-12 12:21:36.750
2009-06-12 12:20:12.627


Regards
Anup



Where do you want to show formatted dates?

Madhivanan

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

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2009-09-08 : 05:13:33
quote:
Originally posted by anup_phansa

Hi

Thanks for your reply

i have try many option of convert function , but does not get exact output ,
please give proper option for convert function that give exact output

Regards
anup




you will have to use more than one style and concatenate it

select convert(varchar(11), getdate(), 113)
+ right(convert(varchar(20), getdate(), 100), 8)


It will be much easier to do it in your front end application. Why aren't you do it there ?


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

Go to Top of Page

anup_phansa
Starting Member

6 Posts

Posted - 2009-09-08 : 06:50:10

Hi thank for youre reply , it's great , i get solution
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2009-09-08 : 08:42:59
quote:
Originally posted by anup_phansa


Hi thank for youre reply , it's great , i get solution



Have you read my first reply?

Madhivanan

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

bklr
Master Smack Fu Yak Hacker

1693 Posts

Posted - 2009-09-10 : 00:29:34
go through these links
http://www.sql-server-helper.com/tips/date-formats.aspx
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=80563
Go to Top of Page
   

- Advertisement -