Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9018655
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T04:34:58+00:00 2026-06-16T04:34:58+00:00

I have some database where the previous err…person has put the date format in

  • 0

I have some database where the previous err…person has put the date format in as 20121218, is it possible to use this as a date in mysql so

SELECT substr(week_begin_date,0,4)+'-'+substr(week_begin_date,4,2)+'-'+substr(week_begin_date,6,8) 
AS startdate 
FROM table 
WHERE startdate < now() 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T04:35:02+00:00Added an answer on June 16, 2026 at 4:35 am

    As stated in Date and Time Literals:

    MySQL recognizes DATE values in these formats:

    • As a string in either 'YYYY-MM-DD' or 'YY-MM-DD' format. A “relaxed” syntax is permitted: Any punctuation character may be used as the delimiter between date parts. For example, '2012-12-31', '2012/12/31', '2012^12^31', and '2012@12@31' are equivalent.

    • As a string with no delimiters in either 'YYYYMMDD' or 'YYMMDD' format, provided that the string makes sense as a date. For example, '20070523' and '070523' are interpreted as '2007-05-23', but '071332' is illegal (it has nonsensical month and day parts) and becomes '0000-00-00'.

    • As a number in either YYYYMMDD or YYMMDD format, provided that the number makes sense as a date. For example, 19830905 and 830905 are interpreted as '1983-09-05'.

    Therefore 20121218 is actually a valid date literal. Therefore:

    SELECT DATE(`week_begin_date`) AS `startdate`
    FROM   `table`
    WHERE  DATE(`week_begin_date`) < NOW()
    

    See it on sqlfiddle.

    However, for the longer-term, you would be wise to fix your schema (and, obviously, any application code that expects to read values in the existing format):

    ALTER TABLE `table` MODIFY week_begin_date DATE
    

    See it on sqlfiddle.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some data in the database, in this format: Description~Level||Description~Level|| I want to
I have a mysql database that is UTF8 encoded. However, due to some previous
I have table that shows some records from database. each table has a column
I have some html stored in database . I dont know that html stored
I have some data in a database that I need represented in an XML
I have some information in my database like 'author', 'book' etc., that are all
i have some fields in my database table,and a field with phone name ,
I have some words in my database. I want to find all the words
I have some task regarding do operations on database using ADODB in Vb.NET. Can
I have some files stored in a database blob column in Oracle 9. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.