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 727075
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T06:31:34+00:00 2026-05-14T06:31:34+00:00

I want to retrieve the left 3 numbers from an integer to be stored

  • 0

I want to retrieve the left 3 numbers from an integer to be stored in a table. For example, if the int is 1234567, I want to retrieve 123. I want the second number (123) to also be an int; I don’t want to convert anything to a string.

(And yes, really I should be working with strings. But I don’t have control over that aspect of the issue.)

Thank you!

  • 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-05-14T06:31:34+00:00Added an answer on May 14, 2026 at 6:31 am

    For SQL Server, the easiest way would definitely be:

    SELECT CAST(LEFT(CAST(YourInt AS VARCHAR(100)), 3) AS INT)
    

    Convert to string, take the left most three characters, and convert those back to an INT.

    Doing it purely on the numerical value gets messy since you need to know how many digits you need to get rid of and so forth…

    If you want to use purely only INT’s, you’d have to construct something like this (at least you could do this in SQL Server – I’m not familiar enough with Access to know if that’ll work in the Access SQL “dialect”):

    DECLARE @MyInt INT = 1234567
    
    SELECT
        CASE 
            WHEN @MyInt < 1000 THEN @MyInt
            WHEN @MyInt > 10000000 THEN @MyInt / 100000
            WHEN @MyInt > 1000000 THEN @MyInt / 10000
            WHEN @MyInt > 100000 THEN @MyInt / 1000
            WHEN @MyInt > 10000 THEN @MyInt / 100
            WHEN @MyInt > 1000 THEN @MyInt / 10
        END AS 'NewInt'
    

    But that’s always an approximation – what if you have a really really really large number….. it might just fall through the cracks….

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

Sidebar

Related Questions

I want to retrieve all records from one table when there are no matches
I want to retrieve the email address from the table and using that to
I want to retrieve the most recent requestid from table tblquoteproposal` for perticular customerId
I want to retrieve a set of records from a database, do a rs.next()
I want to retrieve items from Fortress via its .NET API and load their
I want to retrieve stack trace from a user dump file programmatically . There
I want to retrieve a list of people's names from a queue and, for
I want to retrieve the moth from a date(in textbox),then If that retrieved month
I want to retrieve data from sqlite. user can have more than 1 score
I have 4 tables with the following relevant information I want to retrieve. Table:

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.