using System;
using System.Data;
using System.Data.SqlClient;
using System.Data.SqlTypes;
using Microsoft.SqlServer.Server;
using System.Globalization;
public partial class UserDefinedFunctions
{
[Microsoft.SqlServer.Server.SqlFunction]
public static DateTime ToConvertDate(string date,string fmt)
{
DateTime dt =Convert.ToDateTime(null);
try
{
DateTimeFormatInfo dtFormat = new DateTimeFormatInfo();
dtFormat.ShortDatePattern = fmt;
dt = Convert.ToDateTime( date, dtFormat);
}
catch
{ };
return dt;
}
}
CREATE FUNCTION [dbo].[ToConvertDate](@date nVARCHAR (100),@fmt nVARCHAR(100))
RETURNS DATETIME
as
EXTERNAL NAME [Database3].[UserDefinedFunctions].[ToConvertDate]
SELECT dbo.ToConvertDate('1/2019/2 11:21:01','dym')