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

  • SEARCH
  • Home
  • 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 124001
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T04:22:34+00:00 2026-05-11T04:22:34+00:00

I have a table with a row that looks like this: ( 20091231 48498429,

  • 0

I have a table with a row that looks like this:

(2009123148498429, ‘…’, ‘…’)

The first part, id, is a timestamp followed by a random number. (needed to work with other parts in the system) The data already exists in the table.

I want to create a column, timestamp, and extract just the date (20091231) and update all the rows with the timestamp.

  1. How can I do this for all the rows with SQL? (i.e. update them all with some sort of a function?)
  2. What kind of default value should I assign the column to make sure that future inserts correctly extract the date?

UPDATE – Please read the comments by bobince in the first answered question by Jonathan Sampson on how we got to the answer. This is the final query that worked:

UPDATE table SET rdate=substring(convert(rid,char(20)),1,8); 

The problem was that I was using substring as substring( str, 0, 8 ) whereas it should be substring( str, 1, 8 ). I guess we’re all used to 0 as the beginning position! More info here on substring

Related to: multiple updates in mysql

  • 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. 2026-05-11T04:22:35+00:00Added an answer on May 11, 2026 at 4:22 am
    SELECT SUBSTRING(colDate,0,8) as 'date'  FROM someTable 

    Or am I mistaken?

    UPDATE someTable SET newDateField = SUBSTRING(colDate,0,8) 

    Would likely work too. Untested.

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

Sidebar

Related Questions

I have a schema design that looks like this: Table: User Row Column Family
I have a dynamic table row created via PHP that looks like this: while($carrier
I have a 10 million+ row table that looks like this: id | time_read
I have a multi-row insert that looks something like: insert into table VALUES (1,
I have a table that looks like this: <table name=exercises id=workout-table> <tr> <th>Name</th> <th>Reps/Intervals</th>
I have a table that looks like this: ID / Description / textValue /
I have a table that looks like this(this is just some of the records
I have a MySQL table that looks like this: index | tag | posts
Here's my problem: I have an HTML table that looks like this: What I
I have a table that looks like this user_id | name | created_on |

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.