SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Evangelist cms9651's Avatar
    Join Date
    Mar 2010
    Posts
    407
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Convert string to datetime

    hi there, hope in your help.

    I need convert string to datetime format AM or PM.

    I tried this, buy the output in null, why?
    Code:
    mysql> SELECT
    	STR_TO_DATE(
    		'16/02/2013-04:35:32 p.m.',
    		'%d/%m/%Y-%H:%i:%s %r'
    	) AS NewDate;
    +---------+
    | NewDate |
    +---------+
    | NULL    |
    +---------+
    1 row in set
    
    mysql>
    Thanks you very much for your help
    I'm really happy for your quickly answer.
    Good bye

  2. #2
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,323
    Mentioned
    63 Post(s)
    Tagged
    3 Thread(s)
    change 'p.m.' to 'PM'
    change %H to %h
    change %r to %p
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  3. #3
    SitePoint Evangelist cms9651's Avatar
    Join Date
    Mar 2010
    Posts
    407
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    thanks
    Thanks you very much for your help
    I'm really happy for your quickly answer.
    Good bye


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •