none
Convert to whole number, no decimal point

    Question

  • How do i convert the following result value to a whole number? meaning i dont want any values after the decimal point

    before example
    55.5999
    9472.7232
    446.3997
    1493.1999
    1236.4002
    1038.4002
    1493.1999
    781.1241

    after example
    55
    9472
    446
    1493
    1236
    1038
    1493
    781

    the script below is used to create the results, but i guess i got to convert it somehow?

    select
    sum((datediff(day,DATEADD(dd, -DAY(data_as_at)+1, data_as_at), data_as_at)+1)*fte)
    from MyTable

    Wednesday, June 01, 2011 10:09 AM

Answers

All replies

  • HI,

    try this

    select cast(ROUND (col,0,1) as int) from tablename


    Thanks and regards, Rishabh , Microsoft Community Contributor
    Wednesday, June 01, 2011 10:11 AM
  • HI,

    try this

    select cast(ROUND (col,0,1) as int) from tablename


    Thanks and regards, Rishabh , Microsoft Community Contributor

    Thanks Rishabh, how can i incorporate your example in my select statement? thanks
    Wednesday, June 01, 2011 10:14 AM
  • select 
    CONVERT(INT,sum((datediff(day,DATEADD(dd, -DAY(data_as_at)+1, data_as_at), data_as_at)+1)*fte))
    from MyTable
    
    
    • Marked as answer by SQL_1980 Wednesday, June 01, 2011 10:37 AM
    Wednesday, June 01, 2011 10:15 AM
  • Hi,

    Why you need to to incorporate this in your select statement.

    Mine is also a select statement


    Thanks and regards, Rishabh , Microsoft Community Contributor
    Wednesday, June 01, 2011 10:16 AM
  • There is a dedicated function for that: FLOOR()

    For example:

     

    SELECT FLOOR(55.5999)
    
    
    

    returns 55

     


    Gert-Jan
    Wednesday, June 01, 2011 2:53 PM
  • There is a dedicated function for that: FLOOR()

    For example:

     

    SELECT FLOOR(55.5999)
    
    
    
    
    
    

    returns 55

     


    Gert-Jan


    Note to future readers of this post:

    This answer is a better answer.

    Wednesday, June 01, 2011 4:06 PM
  • Unless you have negative numbers that is ...

    s

    Wednesday, January 22, 2014 10:05 PM
  • FLOOR() ad CEILING() are built-in ANSI/ISO Standard functions. They are covered in any intro SQL class. 

    --CELKO-- Books in Celko Series for Morgan-Kaufmann Publishing: Analytics and OLAP in SQL / Data and Databases: Concepts in Practice Data / Measurements and Standards in SQL SQL for Smarties / SQL Programming Style / SQL Puzzles and Answers / Thinking in Sets / Trees and Hierarchies in SQL

    Wednesday, January 22, 2014 10:22 PM