Convert date formate 4th april 2008 to default date formate
-
Hi all, i just want to know about how to Convert date formate 4th april 2008 to default date formate.... i write select CONVERT (datetime, '4 July 1997') it shows 1997-07-04 00:00:00.000 but i need select CONVERT (datetime, '4th July 1997') o4th july 1997 to show the default formate... thanks in advance
Thanks Subbu.
-
Hi all, i just want to know about how to Convert date formate 4th april 2008 to default date formate.... i write select CONVERT (datetime, '4 July 1997') it shows 1997-07-04 00:00:00.000 but i need select CONVERT (datetime, '4th July 1997') o4th july 1997 to show the default formate... thanks in advance
Thanks Subbu.
-
The CONVERT function has a number of options for different date formats. Read the documentation and choose the most appropriate format for your requirements.
Paul Marfleet "No, his mind is not for rent To any God or government" Tom Sawyer - Rush
hi paul... thank u for ur response .but i found answer for every formate.... but i need to convert dates like o4 th july 2005 or 3rd august 1997 31st december 2000 22nd july 1997....i.e th,nd,rd,.... to default formate..... 04/07/2005, 03/08/1997 helpe with a function..... i am trying this ,but it convert without th,rd,nd,... if not (@Date IS NULL) BEGIN SET @Date = LEFT(@strPhotoDate,patindex('%|%',@strPhotoDate )-1) SET @Date = replace(@strPhotoDate,'th','') SET @Date = replace(@strPhotoDate,'nd','') SET @Date = replace(@strPhotoDate,'rd','') SET @Date = replace(@strPhotoDate,'st','') SET @Date = replace(@strPhotoDate,',','') set @Date1 = CONVERT(datetime, @Date) --cast(@Date1 as DATETIME) END END like that... thanks in advance
Thanks Subbu.
-
The CONVERT function has a number of options for different date formats. Read the documentation and choose the most appropriate format for your requirements.
Paul Marfleet "No, his mind is not for rent To any God or government" Tom Sawyer - Rush
hi paul... thank u for ur response .but i found answer for every formate.... but i need to convert dates like o4 th july 2005 or 3rd august 1997 31st december 2000 22nd july 1997....i.e th,nd,rd,.... to default formate..... 04/07/2005, 03/08/1997 helpe with a function..... i am trying this ,but it convert without th,rd,nd,... if not (@Date IS NULL) BEGIN SET @Date = LEFT(@strPhotoDate,patindex('%|%',@strPhotoDate )-1) SET @Date = replace(@strPhotoDate,'th','') SET @Date = replace(@strPhotoDate,'nd','') SET @Date = replace(@strPhotoDate,'rd','') SET @Date = replace(@strPhotoDate,'st','') SET @Date = replace(@strPhotoDate,',','') set @Date1 = CONVERT(datetime, @Date) --cast(@GetPhotoDate as DATETIME) END END like that... thanks in advance
Thanks Subbu.
-
The CONVERT function has a number of options for different date formats. Read the documentation and choose the most appropriate format for your requirements.
Paul Marfleet "No, his mind is not for rent To any God or government" Tom Sawyer - Rush
hi paul... thank u for ur response .but i found answer for every formate.... but i need to convert dates like o4 th july 2005 or 3rd august 1997 31st december 2000 22nd july 1997....i.e th,nd,rd,.... to default formate..... 04/07/2005, 03/08/1997 helpe with a function..... i am trying this ,but it convert without th,rd,nd,... if not (@Date IS NULL) BEGIN SET @Date = LEFT(@strPhotoDate,patindex('%|%',@strPhotoDate )-1) SET @Date = replace(@strPhotoDate,'th','') SET @Date = replace(@strPhotoDate,'nd','') SET @Date = replace(@strPhotoDate,'rd','') SET @Date = replace(@strPhotoDate,'st','') SET @Date = replace(@strPhotoDate,',','') set @GetPhotoDate = CONVERT(datetime, @Date) --cast(@GetPhotoDate as DATETIME) END END like that... thanks in advance
Thanks Subbu.
-
hi paul... thank u for ur response .but i found answer for every formate.... but i need to convert dates like o4 th july 2005 or 3rd august 1997 31st december 2000 22nd july 1997....i.e th,nd,rd,.... to default formate..... 04/07/2005, 03/08/1997 helpe with a function..... i am trying this ,but it convert without th,rd,nd,... if not (@Date IS NULL) BEGIN SET @Date = LEFT(@strPhotoDate,patindex('%|%',@strPhotoDate )-1) SET @Date = replace(@strPhotoDate,'th','') SET @Date = replace(@strPhotoDate,'nd','') SET @Date = replace(@strPhotoDate,'rd','') SET @Date = replace(@strPhotoDate,'st','') SET @Date = replace(@strPhotoDate,',','') set @Date1 = CONVERT(datetime, @Date) --cast(@Date1 as DATETIME) END END like that... thanks in advance
Thanks Subbu.
If you are converting these dates for display purposes, you are much better to do it in your UI code.