Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save umidjons/5938829 to your computer and use it in GitHub Desktop.
Save umidjons/5938829 to your computer and use it in GitHub Desktop.
Split string in MySQL with SUBSTRING_INDEX( str, delim, count ) Convert string to mysql date with STR_TO_DATE( str, format )
SELECT SUBSTRING_INDEX('www.mysql.com', '.', 2); /* 'www.mysql' */
SELECT SUBSTRING_INDEX('www.mysql.com', '.', -2); /* 'mysql.com' */
/* split by 'ва' case-insensetively, and convert last date value to mysql date */
SELECT STR_TO_DATE(SUBSTRING_INDEX(LOWER('30.11.2010 ва 01.11.2011'),'ва',-1),'%d.%m.%Y'); /* '2011-11-01' */
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment