I want convert my Hijri Shamsi date '92/2/3' to this format : '92/02/03'
With this code, I get this error :The conversion of a varchar data type to a datetime data type resulted in an out-of-range value.
Declare @Str Varchar(10) = '92/2/3'
Select Convert(Varchar(10), Convert(DateTime, @Str), 111)
How can i change format of date ?
11
, not 111
as your conversion codeYou need to use 11 in the inner convert to tell it what format it is converting FROM
Declare @Str Varchar(10) = '92/2/3'
Select Convert(Varchar(10), Convert(DateTime, @Str,11), 11)