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

Format function in SQL

Hi,

I have a query that contains the following in the WHERE part of the
query:

WHERE....Format(IIf(nz([tblLaserscanmessungen_test.KoerperH])<>0,[tblLaserscanmessungen_test.KoerperH],
IIf(nz([tblRContourmessungen_test.KoerperH])<>0,[tblRContourmessungen_test.KoerperH],
IIf(nz([tblVideomessungen_test.KoerperH])<>0,[tblVideomessungen_test.KoerperH],
[tblVThronmessungen_test.KoerperH]))),"0.0") AS Körperhöhe,....

My problem is, that this changes the data type to a string, I think.
Why can't this value stay a decimal, as it is before the Format()
function is applied? Can I do something about it in the syntax of the
Format function?

In the query design window, I have also changed the Format property for
the Körperhöhe field properties to 0,0 - this works by making the
query output a number, but then later when using the query in a
CopyFromDataset funtion, it goes back to it's original behaviour as a
string.

I have read through the VBA help file on using the Format function, but
cannot get what I want - it keeps giving me a string back as the result
of the search!

Please help.

Nov 13 '05 #1
3 4298
On 1 Feb 2005 03:31:29 -0800, "Jean" <je**********@hotmail.com> wrote:

The Format function returns a variant of subtype string. That's by
design, because it is supposed to be used to format final output. It
appears you perhaps want to round instead. So use a rounding function.

-Tom.

Hi,

I have a query that contains the following in the WHERE part of the
query:

WHERE....Format(IIf(nz([tblLaserscanmessungen_test.KoerperH])<>0,[tblLaserscanmessungen_test.KoerperH],
IIf(nz([tblRContourmessungen_test.KoerperH])<>0,[tblRContourmessungen_test.KoerperH],
IIf(nz([tblVideomessungen_test.KoerperH])<>0,[tblVideomessungen_test.KoerperH],
[tblVThronmessungen_test.KoerperH]))),"0.0") AS Körperhöhe,....

My problem is, that this changes the data type to a string, I think.
Why can't this value stay a decimal, as it is before the Format()
function is applied? Can I do something about it in the syntax of the
Format function?

In the query design window, I have also changed the Format property for
the Körperhöhe field properties to 0,0 - this works by making the
query output a number, but then later when using the query in a
CopyFromDataset funtion, it goes back to it's original behaviour as a
string.

I have read through the VBA help file on using the Format function, but
cannot get what I want - it keeps giving me a string back as the result
of the search!

Please help.


Nov 13 '05 #2
Hi Tom,

I tried your suggestion as follows:

WHERE.......Round(IIf(nz([tblLaserscanmessungen_test.KoerperH])<>0,[tblLaserscanmessungen_test.KoerperH],
IIf(nz([tblRContourmessungen_test.KoerperH])<>0,[tblRContourmessungen_test.KoerperH],
IIf(nz([tblVideomessungen_test.KoerperH])<>0,[tblVideomessungen_test.KoerperH],
[tblVThronmessungen_test.KoerperH]))),2) AS Körperhöhe, ............

But, this has no effect! The numbers for Körperhöhe still have about
8 digits after the decimal.
What am I doing wrong here?

Please help, I'm quite a newbie at this!

Nov 13 '05 #3
Just read a few articles....I should mention that I am using Access
2000, so there should be a built in Round function.

Also, I should say that my locale setting for numbers is 123.456,789,
meaning the decimal sign is a comma (,)

Nov 13 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Melissa | last post by:
What specifically causes the Format event of a report's section to fire? Thanks! Melissa
6
by: Stuart McGraw | last post by:
I am looking for a VBA "format" or "template" function, that is, a function that takes a format string and a varying number of arguments, and substitutes the argument values into the format string...
13
by: Roy Hills | last post by:
I've seen two different function prototype formats used for ANSI C, and I'm unsure as to which is the correct or preferred one. 1st Format (this is what I use) type function(type, type, type);...
4
by: Matt | last post by:
I'm trying to write a shared function that will convert all my phone numbers from format 1234567890 to (123) 456-7890. Here is my function that I wrote: Public Shared Function...
10
by: KJ | last post by:
Hello, Why does this not work? txtMoney.Text.Format("#,##0.00") If I type 100 in txtMoney, it returns #,##0.00 I have never gotten the format function to work in .NET.
10
by: Ron | last post by:
Hello, The following code works in a Form class module but not a standard module: Dim d1 As DateTime Format(d1, "MMMM") In a standard module I get a squigly line saying that an argument has...
16
by: Al Reid | last post by:
First, I'm using vb2005. I have a string that is read from a barcode reader into a TextBox. The string is 6 characters long and represents a date (mmddyy). I want to display it to the user in a...
4
by: sql guy123 | last post by:
HI, I'm pretty new to MS SQL, My problem is setting .... =Format$(Date(),"mm" & "/1/" & "YYYY") (Which is from my MS ACCESS database)
11
by: shsandeep | last post by:
I used the following query to retrieve the date in dd-mon-yyyy format. db2 => SELECT RTRIM(CHAR(DAY(COVG_TYP_STRT_DT))) || '-' || RTRIM(MONTHNAME(COVG_TYP_STRT_DT)) || '-' ||...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
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
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...

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.