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 2005 Forums
 Transact-SQL (2005)
 function for dateformat

Author  Topic 

desikankannan
Posting Yak Master

152 Posts

Posted - 2010-02-17 : 11:05:11
i have stored procedure inside i wrote procedure for date format
USE [smartsystem]
GO
/****** Object: StoredProcedure [dbo].[procstdgaugegrid] Script Date: 02/17/2010 21:19:02 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER procedure [dbo].[procstdgaugegrid]
(
@fldguagekey int
)
as
set nocount on
declare
@key int
set @key = @fldguagekey
select fldguagekey,fldslno,fldgoupper,fldgolower,fldnogolower,fldcerfno, ufn_getdateonly(flddoc),ufn_getdateonly(flddonc) from stdgaugedetail where fldguagekey = @key order by fldslno

my function is ufn_dgedateonly

create FUNCTION [dbo].[ufn_GetDateOnly] ( @pInputDate DATETIME )
RETURNS DATETIME
BEGIN

RETURN CAST(CAST(YEAR(@pInputDate) AS VARCHAR(4)) + '/' +
CAST(MONTH(@pInputDate) AS VARCHAR(2)) + '/' +
CAST(DAY(@pInputDate) AS VARCHAR(2)) AS DATETIME)

END

but if i excute the stored procedure i through error
'ufn_getdateonly' is not a recognized built-in function name.


pls guide me

Desikankannan

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-02-17 : 11:08:54
you should access it along with schemaname as
dbo.ufn_getdateonly(flddoc) etc.

why do you need this function? as told in earlier thread this is something to be worried at front end and its really ugly to do this at sql query level

http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=140010

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2010-02-18 : 01:15:08
Isn't it very easy if you use data.tostring("dd/MM/yyyy") instead of all these code?

Madhivanan

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

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-02-18 : 01:19:26
quote:
Originally posted by madhivanan

Isn't it very easy if you use data.tostring("dd/MM/yyyy") instead of all these code?

Madhivanan

Failing to plan is Planning to fail


May be he loves SQL too much and wants to use for everything

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2010-02-18 : 01:25:32
quote:
Originally posted by visakh16

quote:
Originally posted by madhivanan

Isn't it very easy if you use data.tostring("dd/MM/yyyy") instead of all these code?

Madhivanan

Failing to plan is Planning to fail


May be he loves SQL too much and wants to use for everything

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/




May be he loves writing Complicated code

Madhivanan

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

- Advertisement -