fnMFTextToDate

Signature

dbo.fnMFTextToDate(
    @TextDate   NVARCHAR(25),
    @Character  CHAR(1)
)

Returns

  • DATETIME: parsed date/time value; returns NULL or a fallback date when parsing fails (implementation dependent).

Parameters

  • @TextDate NVARCHAR(25) (required) - Date in text format, e.g., ‘1/13/2009’ or ‘3/1/2017 10:47:44 AM’.

  • @Character CHAR(1) (required) - Delimiter for the date portion, e.g., ‘/’.

Purpose

Convert a date in text format (multiple layouts) to a datetime value.

Examples

SELECT dbo.fnMFTextToDate('1/13/2009', '/');
SELECT dbo.fnMFTextToDate('1/13/2009 05:04:22.007', '/');
SELECT dbo.fnMFTextToDate('1/13/2009 05:04:22.007 a.m.', '/');
SELECT dbo.fnMFTextToDate('3/1/2017 10:47:44 AM', '/');

Changelog

Date

Author

Description

2019-11-01

LC

Expand to include more date formats

2019-09-25

LC

Expand function to include other formats for general use

2019-09-10

LC

Create function for use in licensing