Setting Decimal Places in Access DB

Results 1 to 3 of 3

Thread: Setting Decimal Places in Access DB

  1. #1
    Join Date
    Dec 1969

    Default Setting Decimal Places in Access DB

    Hi All,<BR><BR>I am storing the number of hours of a project in an Access DB. I would like to limit the number of decimal places to tenths of an hour (2.5 for 2 1/2 hours). I set the Field Data Type = "Number" Field Size = "Single, Format = "Fixed", Decimal Places = "1". If I enter 2.75 in my ASP page, the number is stored as 2.8 in the database, but is displayed as 2.75 in my ASP page that is reading the database. How do I limit the displayed ASP page decimal places to 1 decimal place?<BR><BR>Thank you,<BR>Mike

  2. #2
    Join Date
    Dec 1969

    Default RE: Setting Decimal Places in Access DB

    You want something like this...<BR><BR>response.write formatnumber(CSng(mynumber), 1)<BR><BR>You might not need the CSng, but if you don&#039t use it you run the risk of getting a type mismatch error.

  3. #3
    Join Date
    Dec 1969

    Default Use CDbl instead of CSng...

    It *might* not make any difference, but if the value is already a double, then using CSng will do nothing but LOSE precision of the value!<BR><BR>There is zero other advantage in using CSng, so I would just dump this particular function out of my lexicon, were I you.<BR><BR>Just incidentally, the same thing applies to CLng versus CInt. Get CInt out of your head, for the same reasons (well, parallel reasons, if you want to get technical).<BR><BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts