Muflix
Muflix

Reputation: 6778

How to convert D.M.YYYY string to DATETIME?

How can i convert string for example 25.6.2014 to DATETIME datatype ? I tried

SELECT CONVERT(datetime, '25.6.2014')
SELECT CAST ('25.6.2012' AS datetime)

but it return error

The conversion of a varchar data type to a datetime data type resulted in an out-of-range value.

because it take argument like month.date.year

Thank for help

Upvotes: 0

Views: 1639

Answers (2)

I A Khan
I A Khan

Reputation: 8839

you can use

SELECT CONVERT(datetime, '25.6.2014', 103)

for all date time conversion

http://www.sqlusa.com/bestpractices/datetimeconversion/

at above link all date time conversions are given

Upvotes: 0

t-clausen.dk
t-clausen.dk

Reputation: 44326

Try highlightning CONVERT in studio management and press shift F1

SELECT CONVERT(datetime, '25.6.2014', 103)

Upvotes: 2

Related Questions