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 |
|
sent_sara
Constraint Violating Yak Guru
377 Posts |
Posted - 2007-06-25 : 07:20:39
|
| how to convert the below dateformat to '1978-05-12'DEclare @tmp varchar(100)DEclare @test varchar(10)set @tmp='12/05/1978'select @test=convert(char(10),@tmp,102) print @test |
|
|
pbguy
Constraint Violating Yak Guru
319 Posts |
Posted - 2007-06-25 : 07:33:36
|
| convert(datetime, @tmp, 121)--------------------------------------------------S.Ahamed |
 |
|
|
harsh_athalye
Master Smack Fu Yak Hacker
5581 Posts |
Posted - 2007-06-25 : 08:00:29
|
1. conversion formats in CONVERT() function apply only while converting from date to character data.2. Storing dates as character data is bad design3. You can easily accomplish this from the front-end.4. Here is one working solution:Set Dateformat DMYDeclare @tmp varchar(100)set @tmp='12/05/1978'select convert(varchar(10), cast(@tmp as datetime), 121) as FormattedDate Harsh AthalyeIndia."The IMPOSSIBLE is often UNTRIED" |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2007-06-25 : 08:57:52
|
quote: Originally posted by sent_sara how to convert the below dateformat to '1978-05-12'DEclare @tmp varchar(100)DEclare @test varchar(10)set @tmp='12/05/1978'select @test=convert(char(10),@tmp,102) print @test
1 Where do you want to show Formatted date?2 Always use Proper DATETIME to store dates and let front end do formation(If you use it)MadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|