Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 User Defined Function for Oracles TRUNC function

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2005-08-31 : 07:15:35
Deepa writes "We have trunc function in oracle for truncating Number and Date values.

I want a user defined function to mimic the same functionality in SQL server."

robvolk
Most Valuable Yak

15732 Posts

Posted - 2005-08-31 : 07:17:13
You don't need a UDF for it:

SELECT convert(int, num_value) --for numbers
SELECT DateAdd(day, DateDiff(day, 0, date_value), 0)
--for dates
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-08-31 : 07:19:49
For numbers you can use Round function (also Floor, ceiling)
For dates use Convert function

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -