|
sql
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
data conversion
Hi
i have a problem converting a column which contains the date to the date type i want ie mm/dd/yyyy csv source file is y-MMM (e.g. 6-Feb is Feb-2006). When i import the data from the csv source file to the table in sql, it automatically tranformed the data to Feb-06. The data type used is varchar. How can i convert Feb-06 to mm/dd/yyyy format. Kindly advise Tiffany
declare @dt varchar(20) set @dt='Feb-06' select convert(varchar(20),dt,101) from ( select cast('20'+right(@dt,2)+case when left(@dt,3)='Feb' then '02' end+'01' as datetime)as dt ) as d Show quoteHide quote "Tiffany" <Tiff***@discussions.microsoft.com> wrote in message news:1E870F52-8CCB-44DF-B619-BD68B0C49AA0@microsoft.com... > Hi > > i have a problem converting a column which contains the date to the date > type i want ie mm/dd/yyyy > > csv source file is y-MMM (e.g. 6-Feb is Feb-2006). When i import the data > from the csv source file to the table in sql, it automatically tranformed > the > data to Feb-06. The data type used is varchar. How can i convert Feb-06 to > mm/dd/yyyy format. > > Kindly advise > >
Other interesting topics
Installing SQL Server 2000 on WindowsXP
Left outer join v. Union Linked server error in SSMS Query compiling time UPDATE won't execute on 2k5 installation Monitoring free space in database and log files with script Server migration How do I ignore server errors in Stored Proc run via SQL Agent How to Improve SQL Server performance with web application performane issues - can someone explain the connection?.. |
|||||||||||||||||||||||