CAST(SUBSTRING(F1,4,2) + '-' + SUBSTRING(F1,1,2) + '-' + SUBSTRING(F1,7,2) AS datetime)
CONVERT(DATETIME, F1, 105)
http://msdn.microsoft.com/en-us/library/ms187928.aspx
ASKER
-- in your case input is dd-mm-yy (05-16-11)
SELECT [dbo].[ufsFormat] ('05-16-11', 'mm-dd-yyyy') -- Output : 05-16-2011
SELECT [dbo].[ufsFormat] ('05-16-11', 'dd-mm-yyyy') -- Output: 16-05-2011
SELECT [dbo].[ufsFormat] ('05-16-11', 'dd-mm-yy') -- Output: 16-05-11
Try with this. it may help you.Microsoft SQL Server 2005 is a suite of relational database management system (RDBMS) products providing multi-user database access functionality.Component services include integration (SSIS), reporting (SSRS), analysis (SSAS), data quality, master data, T-SQL and performance tuning. It includes support for managing XML data and allows a database server to be exposed over web services using Tabular Data Stream (TDS) packets encapsulated within SOAP (protocol) requests.
TRUSTED BY