- Home /

I ran into something perculiar in SSIS today.

In a Derived Column package I was trying to truncate a numeric value to an integer, like this (DT_I4)[MyNumericValue] It turns out that this does not do a truncate, but it rounds (up or down) to the nearest integer.

So I had to do this to get it to truncate: (DT_I4)FLOOR([MyNumericValue]) I tried searching for an answer, but was not able to find any.

Now there is an explaination to be found.

In a Derived Column package I was trying to truncate a numeric value to an integer, like this (DT_I4)[MyNumericValue] It turns out that this does not do a truncate, but it rounds (up or down) to the nearest integer.

So I had to do this to get it to truncate: (DT_I4)FLOOR([MyNumericValue]) I tried searching for an answer, but was not able to find any.

Now there is an explaination to be found.

Comment

Scot Hauder

**Answer** by Pavel Pawlowski
·
Jun 30, 2011 at 03:24 AM

Only to be completely correct to really truncate (cut off decimal places) from signed numeric value you have to write following expression:
SIGN([MyNumericValue]) * FLOOR(ABS([MyNumericValue]))
As single floor function returns the largest integer value, that is less then or equal to the value provided.
In case of negative value eg. `FLOOR(-1.34)` will return `-2`.

Best way to refresh an entire database daily? 1 Answer

how to delete old flat file in ssis 3 Answers

SSIS Dynamic Mapping 3 Answers

Going Backwards with SSIS Projects - First Prod then Test? 2 Answers

how to create execute package task 0 Answers

Copyright 2019 Redgate Software. Privacy Policy

- Anonymous
- Sign in
- Create
- Ask a question
- Spaces
- Ask SSC Site Issues (meta-askssc)
- Explore
- Topics
- Questions
- Users
- Badges