Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. Convert date formate 4th april 2008 to default date formate

Convert date formate 4th april 2008 to default date formate

Scheduled Pinned Locked Moved Database
tutorial
6 Posts 3 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    subbu sk
    wrote on last edited by
    #1

    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.

    P 1 Reply Last reply
    0
    • S subbu sk

      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.

      P Offline
      P Offline
      pmarfleet
      wrote on last edited by
      #2

      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

      S 3 Replies Last reply
      0
      • P pmarfleet

        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

        S Offline
        S Offline
        subbu sk
        wrote on last edited by
        #3

        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.

        P 1 Reply Last reply
        0
        • P pmarfleet

          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

          S Offline
          S Offline
          subbu sk
          wrote on last edited by
          #4

          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.

          1 Reply Last reply
          0
          • P pmarfleet

            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

            S Offline
            S Offline
            subbu sk
            wrote on last edited by
            #5

            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.

            1 Reply Last reply
            0
            • S subbu sk

              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.

              P Offline
              P Offline
              Paddy Boyd
              wrote on last edited by
              #6

              If you are converting these dates for display purposes, you are much better to do it in your UI code.

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups