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)
 DateTime Columns

Author  Topic 

lemondash
Posting Yak Master

159 Posts

Posted - 2009-04-09 : 05:33:41
Hello all,

Have two columns that i have a small issue with and wonder if anybody can help me solve it.

First have a datatime column. Example of the data '2009-02-17 10:40:25.673' but i want to return it with out the millseconds and seconds'2009-02-17 10:40', have tried different ways using cast and convert but can't get it working.
any ideas ?

Second have a float column. Example of the data '12' but i want to return this as '£12.00' have manged to get this close by using this 'select '£',CAST([Float Column] AS MONEY)' any ideas how i can put £ sign and money colunm together as one.

any help would be great.

Thanks in advance

ayamas
Aged Yak Warrior

552 Posts

Posted - 2009-04-09 : 05:45:55
declare @money float
set @money=12

declare @dt datetime
set @dt='2009-02-17 10:40:25.673'
select '£'+ + Convert(Varchar(10),CAST(@money AS MONEY))

select convert(varchar(20),@dt,111) + ' ' + left(convert(varchar(100),@dt,108),5)
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2009-04-09 : 06:08:16
Both are for formation and if you use front end application, do these formation there

Madhivanan

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

lemondash
Posting Yak Master

159 Posts

Posted - 2009-04-09 : 06:35:39
Can't thank you enough. cheers you are a star.
Go to Top of Page

ayamas
Aged Yak Warrior

552 Posts

Posted - 2009-04-09 : 06:46:27
quote:
Originally posted by lemondash

Can't thank you enough. cheers you are a star.


And who's that?
Go to Top of Page
   

- Advertisement -