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 Text to datetime

Convert Text to datetime

Scheduled Pinned Locked Moved Database
questionmysqlcomannouncement
4 Posts 3 Posters 0 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.
  • J Offline
    J Offline
    Jassim Rahma
    wrote on last edited by
    #1

    Hi, I have below date text and I want to know how can I convert it to valid MySQL datetime which is yyyy-mm-dd HH:mm Nov 20 2015 10:51AM Nov 20 2015 10:16PM Nov 20 2015 10:01AM Nov 20 2015 8:43PM Nov 20 2015 8:04PM Nov 20 2015 5:49PM Nov 20 2015 5:38PM Nov 20 2015 5:23PM Nov 20 2015 5:03PM Nov 20 2015 4:57PM Nov 20 2015 2:10PM Nov 20 2015 1:51PM Nov 19 2015 12:24AM Nov 19 2015 11:56AM Nov 19 2015 11:32PM Nov 19 2015 11:27PM Nov 19 2015 10:15AM Nov 19 2015 10:12PM How can I do this please? Thanks, Jassim[^]

    Technology News @ www.JassimRahma.com

    N 1 Reply Last reply
    0
    • J Jassim Rahma

      Hi, I have below date text and I want to know how can I convert it to valid MySQL datetime which is yyyy-mm-dd HH:mm Nov 20 2015 10:51AM Nov 20 2015 10:16PM Nov 20 2015 10:01AM Nov 20 2015 8:43PM Nov 20 2015 8:04PM Nov 20 2015 5:49PM Nov 20 2015 5:38PM Nov 20 2015 5:23PM Nov 20 2015 5:03PM Nov 20 2015 4:57PM Nov 20 2015 2:10PM Nov 20 2015 1:51PM Nov 19 2015 12:24AM Nov 19 2015 11:56AM Nov 19 2015 11:32PM Nov 19 2015 11:27PM Nov 19 2015 10:15AM Nov 19 2015 10:12PM How can I do this please? Thanks, Jassim[^]

      Technology News @ www.JassimRahma.com

      N Offline
      N Offline
      NickPace
      wrote on last edited by
      #2

      This should work: SELECT DATE_FORMAT(STR_TO_DATE('Nov 20 2015 10:51AM', '%b %d %Y %h:%i%p'), '%Y-%m-%d %H:%i'); #Returns 2015-11-20 10:51 SELECT DATE_FORMAT(STR_TO_DATE('Nov 20 2015 8:43PM', '%b %d %Y %h:%i%p'), '%Y-%m-%d %H:%i'); #Returns 2015-11-20 20:43

      -NP Never underestimate the creativity of the end-user.

      M 1 Reply Last reply
      0
      • N NickPace

        This should work: SELECT DATE_FORMAT(STR_TO_DATE('Nov 20 2015 10:51AM', '%b %d %Y %h:%i%p'), '%Y-%m-%d %H:%i'); #Returns 2015-11-20 10:51 SELECT DATE_FORMAT(STR_TO_DATE('Nov 20 2015 8:43PM', '%b %d %Y %h:%i%p'), '%Y-%m-%d %H:%i'); #Returns 2015-11-20 20:43

        -NP Never underestimate the creativity of the end-user.

        M Offline
        M Offline
        Mycroft Holmes
        wrote on last edited by
        #3

        Wow doesn't MySQL have the convert function? SELECT CONVERT(DATETIME,'Nov 20 2015 8:43PM') Is the SQL Server method, so simples!

        Never underestimate the power of human stupidity RAH

        N 1 Reply Last reply
        0
        • M Mycroft Holmes

          Wow doesn't MySQL have the convert function? SELECT CONVERT(DATETIME,'Nov 20 2015 8:43PM') Is the SQL Server method, so simples!

          Never underestimate the power of human stupidity RAH

          N Offline
          N Offline
          NickPace
          wrote on last edited by
          #4

          It does have a CONVERT method but it won't work with that format of text dates. That was the first thing I tried.

          -NP Never underestimate the creativity of the end-user.

          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