SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

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

AskSQLTeam
Ask SQLTeam Question

USA
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."

robvolk
Most Valuable Yak

USA
15675 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

madhivanan
Premature Yak Congratulator

India
22761 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

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
  Previous Topic Topic Next Topic  
 New 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.16 seconds. Powered By: Snitz Forums 2000