Skip to content

Instantly share code, notes, and snippets.

@umidjons
Created July 5, 2013 11:08
Show Gist options
  • Save umidjons/5933834 to your computer and use it in GitHub Desktop.
Save umidjons/5933834 to your computer and use it in GitHub Desktop.
Convert (Excel date) 5 digit numbers to date in mysql
SELECT
iar_d AS date_5_num, /* numbers like: 40479, 40298, 39038, 41075 */
DATE('1899-12-30') + INTERVAL iar_d DAY AS normal_date /* converted dates */
FROM registry_private_clinics
WHERE iar_d REGEXP '^[0-9]{5}$' /* only rows with NNNNN format, where N is [0-9] */
@sdrahan
Copy link

sdrahan commented Oct 8, 2019

Thank you for this snippet! Worked like a charm for me.

@TammyLaforest
Copy link

Thank you!

@zinnatik24
Copy link

Wonderful!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment