SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Thread: Convert string to datetime

  1. #1
    SitePoint Addict cms9651's Avatar
    Join Date
    Mar 2010
    Posts
    387
    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 silver trophybronze trophy
    SitePoint Award Recipient r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    38,464
    Mentioned
    35 Post(s)
    Tagged
    1 Thread(s)
    change 'p.m.' to 'PM'
    change %H to %h
    change %r to %p
    r937.com | rudy.ca | Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  3. #3
    SitePoint Addict cms9651's Avatar
    Join Date
    Mar 2010
    Posts
    387
    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
  •