STR_TO_DATE(str,format) : STR_TO_DATE « Date Time Functions « MySQL Tutorial

Home
MySQL Tutorial
1.Introduction
2.Select Query
3.Database
4.Table
5.Table Join
6.Subquery
7.Insert Update Delete
8.Logic Operator
9.View
10.Data Types
11.Procedure Function
12.Cursor
13.Trigger
14.Date Time Functions
15.Comparison Functions Operators
16.Aggregate Functions
17.Cast Functions Operators
18.Control Flow Functions
19.Encryption Compression Functions
20.Information Functions
21.Math Numeric Functions
22.Miscellaneous Functions
23.String Functions
24.Regular Expressions
25.Data Dictionary
26.MySQL Utilities
27.Privilege
MySQL Tutorial » Date Time Functions » STR_TO_DATE 
14.39.1.STR_TO_DATE(str,format)

STR_TO_DATE(str,format) is the inverse of the DATE_FORMAT() function.

STR_TO_DATE() returns a DATETIME value.

The following specifiers may be used in the format string.

The '%' character is required before format specifier characters.

SpecifierDescription
%aAbbreviated weekday name (Sun..Sat)
%bAbbreviated month name (Jan..Dec)
%cMonth, numeric (0..12)
%DDay of the month with English suffix (0th, 1st, 2nd, 3rd, ?-)
%dDay of the month, numeric (00..31)
%eDay of the month, numeric (0..31)
%fMicroseconds (000000..999999)
%HHour (00..23)
%hHour (01..12)
%IHour (01..12)
%iMinutes, numeric (00..59)
%jDay of year (001..366)
%kHour (0..23)
%lHour (1..12)
%MMonth name (January..December)
%mMonth, numeric (00..12)
%pAM or PM
%rTime, 12-hour (hh:mm:ss followed by AM or PM)
%SSeconds (00..59)
%sSeconds (00..59)
%TTime, 24-hour (hh:mm:ss)
%UWeek (00..53), where Sunday is the first day of the week
%uWeek (00..53), where Monday is the first day of the week
%VWeek (01..53), where Sunday is the first day of the week; used with %X
%vWeek (01..53), where Monday is the first day of the week; used with %x
%WWeekday name (Sunday..Saturday)
%wDay of the week (0=Sunday..6=Saturday)
%XYear for the week where Sunday is the first day of the week, numeric, four digits; used with %V
%xYear for the week, where Monday is the first day of the week, numeric, four digits; used with %v
%YYear, numeric, four digits
%yYear, numeric (two digits)
%%A literal '%' character
%xx, for any 'x' not listed above


14.39.STR_TO_DATE
14.39.1.STR_TO_DATE(str,format)
14.39.2.SELECT STR_TO_DATE('00/00/0000', '%m/%d/%Y');
14.39.3.SELECT STR_TO_DATE('04/31/2004', '%m/%d/%Y');
14.39.4.To convert a year-week to a date, then you should also specify the weekday:
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.