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

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
Save Password
Forgot your Password?

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 User Defined Function for Oracles TRUNC function
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Ask SQLTeam Question

0 Posts

Posted - 08/31/2005 :  07:15:35  Show Profile  Visit AskSQLTeam's Homepage  Reply with Quote
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."

Most Valuable Yak

15732 Posts

Posted - 08/31/2005 :  07:17:13  Show Profile  Visit robvolk's Homepage  Reply with Quote
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

Premature Yak Congratulator

22864 Posts

Posted - 08/31/2005 :  07:19:49  Show Profile  Send madhivanan a Yahoo! Message  Reply with Quote
For numbers you can use Round function (also Floor, ceiling)
For dates use Convert function


Failing to plan is Planning to fail
Go to Top of Page
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.03 seconds. Powered By: Snitz Forums 2000