Showing posts with label datatype. Show all posts
Showing posts with label datatype. Show all posts

Tuesday, March 20, 2012

problem with float data type

Hi all,
I have declared a field with datatype as float.
When I enter value with two precision it chooses to round off to lower value and insert into the database.

I am losing precision in this case.

I want to insert 4.56. It inserts the way shown and hence all my further calculations go haywire.

Is SQL server designed to store float like this or Am I doing soemting wrong ?

Please advise...

4.56 (Inserted)

4.5599999999999996 (Stored)Generally you have to convert the value that is being inserted into the database, or you can convert it when it is pulled from the DB. I prefer to do it beforehand.

If you do something like this it should work:

Dim Val1 as Int16

Val1 = Convert.ToInt16(TextBox1.text)

Saturday, February 25, 2012

problem with datetime datatype..

hi! can anybody pls. help me...is it posible for my 'date' column with datetime datatype to contain date only..without the date? any inputs will be greatly appreciated!!if you are talking about microsoft sql server, the answer is no, you cannot have only a date without a time

however, you can have a date with a midnight time, e.g. 2006-05-29 00:00:00

use dateadd(d,datediff(d,0,getdate()),0)

moving thread to microsoft sql server forum (if you're using some other database, please be sure to mention it)