String to date in MySQL

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • klazuzu2
    New Member
    • Aug 2007
    • 1

    String to date in MySQL

    Hi,

    I have a date string in MySQL (varchar) in the format YYYYMMDDDHHMM (saved from a xml document) . I would like to convert the string to give me the format DD.MM.YYYY HH:MM when i do a select on the string.

    Any ideas?
  • ronverdonk
    Recognized Expert Specialist
    • Jul 2006
    • 4259

    #2
    This is a MySQL question, so I'll move the thread.
    Originally posted by klazuzu2
    Hi,

    I have a date string in MySQL (varchar) in the format YYYYMMDDDHHMM (saved from a xml document) . I would like to convert the string to give me the format DD.MM.YYYY HH:MM when i do a select on the string.

    Any ideas?
    Welcome to TSDN!

    Try this one
    Code:
    SELECT DATE_FORMAT(STR_TO_DATE('200802281011','%Y%m%d %h%i'), '%d.%m.%Y %H:%i');
    results in 28.02.2008 10:11

    Ronald
    Last edited by ronverdonk; Feb 27 '08, 01:59 PM. Reason: move to other forum

    Comment

    Working...