Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 239
  • Last Modified:

Input of numeric data into a field w/datatype of float

I need a way to update a field in a table with a numeric number.  The field (Hours) has a datatype of "float"  so if were to update this field like so

Update Issues
set hours = '4.0'
where issuenumber = 'xxxx'

I get a displayed number that doesn't resemble the intended 4.0 hours.

So I'm looking perhaps for a sql function that will take the 4.0 hours and convert and imput them into the database so that when displayed shows the 4.0 hours.

Any help will be appreciated.

  • 2
2 Solutions
Daniel WilsonCommented:
What DBMS?

Typically, omit the quotes around a number.

Update Issues
set hours = 4.0
where issuenumber = 'xxxx'
TimSweet220Author Commented:
MS SQL 2000

The display is in asp and when I run the query above
 the asp page displays  96:00 instead of 4:00

Now if entered through the asp display for example 88 hours the database shows 3.6666666666666665.  So I guess the asp is doing the converting when updating to the database.

I may have to take this off to another section - but I was hoping to be able to update on the dbside rather then enter by hand in the asp pages.

Are you actually using a date field?

Suggest that the database is seeing 4.0 as 4 days and that it is returning 96:00 - 4 x 24 - i.e. 4 days in hours.
Daniel WilsonCommented:
In MS SQL Server, the SQL above will put the right figure into the DB.

Whether your ASP, either providing the number or displaying it on retrieval, is applying other formatting, is hard to say without a look at that code.

The fieldtype in the DB is "float", right?  Your variable in your ASP ... is that Single?  double?  Either of those should do fine.

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now