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 |
|
victord
Yak Posting Veteran
64 Posts |
Posted - 2002-07-12 : 10:37:12
|
| Dear Folks,How do i convert a datetime datatype to varchar datatype in the format 'mm/dd/yy' and then add a numeric string e.g '002' + 'mm/dd/yy', output 00206/13/05. And vice versa , i mean how to convert back to datatype from varchar.Thanks in advance,V David |
|
|
joshb
Yak Posting Veteran
52 Posts |
Posted - 2002-07-12 : 10:52:02
|
| Something like this:DECLARE @Date smalldatetimeDECLARE @VcDate varchar(50)SET @Date = '04/05/79'SET @VcDate = '002' + CONVERT(varchar, @Date, 1)SELECT @VcDateSET @Date = CONVERT(smalldatetime, RIGHT(@VcDate, 8))SELECT @DateThe key is the style argument (last argument of CONVERT).Josh |
 |
|
|
|
|
|