473,396 Members | 1,929 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,396 software developers and data experts.

Update query to certain number format

76
I'm trying to figure out how to get an update query to work. I need to get dollar amounts into standard lengths and formats for export into our main system. The dollar amounts need to be 17 digits with zero's to the left and no decimal. For example:

$7.26 becomes 00000000000000726
$24,974.57 becomes 00000000002497457

and so on.

Can anyone help with what formula to put into the Update To: section of the query???
Nov 3 '09 #1

✓ answered by ADezii

@ckpoll2
With a Currency Field, you may be better off displaying your results in a Calculated Field. Assuming your Table name is tblProject, and your Currency Field is [Amount], to Format the results in a Calculated Field named [Converted_Amount] to 17 digits with leading zeros, no Decimals, and the 2 rightmost digits representing cents:
Expand|Select|Wrap|Line Numbers
  1. SELECT tblProject.Amount, Format(100*[Amount],"00000000000000000") AS Converted_Amount
  2. FROM tblProject
  3. WHERE (((tblProject.Amount) Is Not Null));
Sample OUTPUT:
Expand|Select|Wrap|Line Numbers
  1. Amount            Converted_Amount
  2. $7.26             00000000000000726
  3. $24,974.57        00000000002497457
  4. $85.00            00000000000008500
  5. $1.03             00000000000000103
  6.  

4 3672
ADezii
8,834 Expert 8TB
@ckpoll2
With a Currency Field, you may be better off displaying your results in a Calculated Field. Assuming your Table name is tblProject, and your Currency Field is [Amount], to Format the results in a Calculated Field named [Converted_Amount] to 17 digits with leading zeros, no Decimals, and the 2 rightmost digits representing cents:
Expand|Select|Wrap|Line Numbers
  1. SELECT tblProject.Amount, Format(100*[Amount],"00000000000000000") AS Converted_Amount
  2. FROM tblProject
  3. WHERE (((tblProject.Amount) Is Not Null));
Sample OUTPUT:
Expand|Select|Wrap|Line Numbers
  1. Amount            Converted_Amount
  2. $7.26             00000000000000726
  3. $24,974.57        00000000002497457
  4. $85.00            00000000000008500
  5. $1.03             00000000000000103
  6.  
Nov 3 '09 #2
ckpoll2
76
You are amazing!! Thanks so much for your help!!
Nov 3 '09 #3
NeoPa
32,556 Expert Mod 16PB
Very much along the lines ADezii has already suggested :
Expand|Select|Wrap|Line Numbers
  1. SELECT [Amount],
  2.        Format(100*[Amount],String(17,'0')) AS Converted_Amount
  3. FROM   tblProject
  4. WHERE  ([Amount] Is Not Null)
Nov 3 '09 #4
ckpoll2
76
You guys are great. Thanks again!!
Nov 3 '09 #5

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

Similar topics

16
by: Philip Boonzaaier | last post by:
I want to be able to generate SQL statements that will go through a list of data, effectively row by row, enquire on the database if this exists in the selected table- If it exists, then the colums...
16
by: robert | last post by:
been ruminating on the question (mostly in a 390/v7 context) of whether, and if so when, a row update becomes an insert/delete. i assume that there is a threshold on the number of columns of the...
3
by: Ken Bush | last post by:
How can I write an update query that removes part of a field? Like if I have a field with values such as 8/3/68 (a birthday obviously) and I need to put values in a new column but I need...
2
by: nadmasl | last post by:
I have an MS Access form, where a user enters the date by selecting it from three combo boxes for day, month and year. I convert it to 11-Jan-2004 format and attempt to write to the table with an...
0
by: Dalan | last post by:
I'm not certain if this is doable in the manner explained below, but I'm certain that there have been Access developers who have done something similar. So whatever insight and assistance that can...
8
by: Maxi | last post by:
There is a lotto system which picks 21 numbers every day out of 80 numbers. I have a table (name:Lotto) with 22 fields (name:Date,P1,P2....P21) Here is the structure and sample data: ...
3
by: Bob Bedford | last post by:
hello I'm looking for some functions or objects allowing to select-insert-update-delete from any table in a mysql database without the need to create a new query every time. Example: ...
1
by: jmarcrum | last post by:
Hey everyone, I have a question that's been troubling me for a bit. I work for Alabama Power. I have 1 table (tblOutages). Every morning I import a list of Power Outages for the state of...
3
by: Michel Esber | last post by:
Hi all, DB2 V8 LUW FP 15 There is a table T (ID varchar (24), ABC timestamp). ID is PK. Our application needs to frequently update T with a new value for ABC. update T set ABC=? where ID...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.