Please start any new threads on our new site at http://forums.sqlteam.com. 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
 
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
 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
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

madhivanan
Premature Yak Congratulator

India
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

Madhivanan

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.13 seconds. Powered By: Snitz Forums 2000