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.
Author |
Topic |
allan8964
Posting Yak Master
249 Posts |
Posted - 2013-10-12 : 12:27:48
|
Hi there,To change string '24.04.2013' (Apr. 24, 2013 format of dd-mm-yyyy) into a date in format of mm-dd-yyyy, what's the easiest way?Thanks in advance. |
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2013-10-12 : 12:40:52
|
declare @date varchar(12)set @date='24.04.2013'select convert(char(10),convert(datetime,@date,103),110)But this is really not needed if you store datetime values in proper datetime datatype and leave formation at front end applicationMadhivananFailing to plan is Planning to fail |
|
|
allan8964
Posting Yak Master
249 Posts |
Posted - 2013-10-12 : 13:01:31
|
Ok, turn it into British date then make it string in US way. Cool!The data are imported from SSIS package as string and saved in a varchar column, that's why it needs format changed.Thanks madhivanan! |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2013-10-12 : 13:53:09
|
quote: Originally posted by allan8964 Ok, turn it into British date then make it string in US way. Cool!The data are imported from SSIS package as string and saved in a varchar column, that's why it needs format changed.Thanks madhivanan!
then you should be fixing this in ssis and bringing them as dates itself. that will save you lot of convertion issues------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/https://www.facebook.com/VmBlogs |
|
|
allan8964
Posting Yak Master
249 Posts |
Posted - 2013-10-12 : 14:05:13
|
Agree. Visakh16. But it's a global corporate and different team charge each other for those kind of changes! Project manager won't pay for that. |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2013-10-13 : 01:33:20
|
quote: Originally posted by allan8964 Agree. Visakh16. But it's a global corporate and different team charge each other for those kind of changes! Project manager won't pay for that.
Ok but keep in mind that if date values are not coming in consistent way this may cause errors while converting.------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/https://www.facebook.com/VmBlogs |
|
|
|
|
|