473,386 Members | 1,823 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

format field

266 256MB
i have a field with numbers in it and was wondering if i can do a query to only keep the last 4 digits in the field. thanks!
May 4 '09 #1
7 2553
ADezii
8,834 Expert 8TB
@didacticone
Is it a Whole Number Field (INTEGER, LONG) or Floating Point (SINGLE, DOUBLE)?
May 4 '09 #2
didacticone
266 256MB
its a long integer field
May 4 '09 #3
FishVal
2,653 Expert 2GB
I guess last 4 digits of long integer is remainder of division by 10000.

= SomeLongIntegerNumber mod 10000
May 4 '09 #4
ADezii
8,834 Expert 8TB
@didacticone
I'm running out the door, and I'm sure that there is an easier way, but here is what I come up with in a flash:
Expand|Select|Wrap|Line Numbers
  1. Public Function fFormatLong(lngNumber As Long) As String
  2.   fFormatLong = Format(((lngNumber / 10000) - Fix(lngNumber / 10000)) * 10000, "0000")
  3. End Function
SAMPLE RESULTS:
Expand|Select|Wrap|Line Numbers
  1. Debug.Print fFormatLong(1)
  2. 0001
  3.  
  4. Debug.Print fFormatLong(27) 
  5. 0027
  6.  
  7. Debug.Print fFormatLong(892)
  8. 0892
  9.  
  10. Debug.Print fFormatLong(4320)
  11. 4320
  12.  
  13. Debug.Print fFormatLong(16230)
  14. 6230
  15.  
  16. Debug.Print fFormatLong(999992)
  17. 9992
  18.  
  19. Debug.Print fFormatLong(1234567)
  20. 4567
May 4 '09 #5
OldBirdman
675 512MB
And with no arithmetic:
Expand|Select|Wrap|Line Numbers
  1. Right(Format(lngNumber ,"0000"),4)
May 4 '09 #6
ADezii
8,834 Expert 8TB
@didacticone
didacticone, pay absolutely no attention to what that ADezii Character gave as a Reply in Post #5! Do, however, follow OldBirdman's advice in Post #6! (LOL)!
May 4 '09 #7
NeoPa
32,556 Expert Mod 16PB
Not forgetting Fish's suggestion in post #4. Hard to beat for a concise answer.
May 6 '09 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Dalan | last post by:
This should not be an issue, but it is. I'm sure that someone knows what little piece of code is needed too persuade Access 97 to include a currency format for labels (Avery, mailing type). Have...
5
by: Macca | last post by:
Hi, I have a table which has a date/time field. I am storing them as follows :- 01/01/2005 11:25 01/01/2005 19:44 02/01/2005 05:04
1
by: Julius Fenata | last post by:
Dear all, I need help to change my item-template value format... Here is my case, I have a datagrid, with 'SubjectPrice' field, and when the grid displayed, my 'SubjectPrice' field displayed...
9
by: David Rysdam | last post by:
I have a large amount of data that I copy in and out of Sybase very often. Now I also want to copy this data in and out of postgres. I have an existing script that creates the entire database(s)...
1
by: scott | last post by:
Hi Everyone, I don't know if this is the correct forum but I thought i'd ask. I have an access DB with a function to automatically safe a table with fields i'm mail merging into MS Word. Word...
6
by: Ted | last post by:
I used bcp to produce the apended format file. How can it be modified to recognize the quotes that surround the text fields and not insert the quotes along with the text? Invariably, the first...
9
by: RMC | last post by:
Hello, I'm looking for a way to parse/format a memo field within a report. The Access 2000 database (application) has an equipment table that holds a memo field. Within the report, the memo...
10
by: Dixie | last post by:
I am appending some new fields to a table in vba and when I append a number field with is a byte, it does not inherit any format. I want it to be the General Number format, but it is blank. I...
10
by: ARC | last post by:
Hello all, General question for back-end database that has numerous date fields where the database will be used in regions that put the month first, and regions that do not. Should I save a...
3
by: Bface | last post by:
Hi all, Hope everyone had a good holiday. I am having a difficult time changing the date format of a field from Excel. I have never had this problem before. I link the excel spreadsheet to my DB,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.