ok sir  i did that.. but m having the problem with date diff function

On Fri, Jan 28, 2011 at 1:42 PM, Stefan Brandt <[email protected]> wrote:

> hmm...get_Month_Days function looks funny...why are you not just
> putting a datetime as parameter?
>
> The function could be done like this:
>
> CREATE FUNCTION [dbo].[get_Month_Days] ( @szfd_date DATETIME )
> RETURNS INT
> AS
> BEGIN
>    RETURN CASE WHEN MONTH(@szfd_date) IN (1, 3, 5, 7, 8, 10, 12) THEN
> 31
>                WHEN MONTH(@szfd_date) IN (4, 6, 9, 11) THEN 30
>                ELSE CASE WHEN (YEAR(@szfd_date) % 4    = 0 AND
>                                YEAR(@szfd_date) % 100 != 0) OR
>                               (YEAR(@szfd_date) % 400  = 0)
>                          THEN 29
>                          ELSE 28
>                     END
>           END
> END
>
>
> or like this:
>
> CREATE FUNCTION [dbo].[get_Month_Days] (@szfd_date DATETIME)
> RETURNS INT
> AS
> BEGIN
>    SET @szfd_date = CONVERT(VARCHAR(10), @szfd_date, 101)
>    SET @szfd_date = @szfd_date - DAY(@szfd_date) + 1
>
>    RETURN DATEDIFF(DD, @szfd_date, DATEADD(MM, 1, @szfd_date))
> END
>
> Make less conversions and think more simple...the solution is more
> simple than you can imagine :)
>
>
>
> On Jan 27, 12:07 pm, The Master Mind <[email protected]> wrote:
> > the return value is varchar..
> > i send one handle
> > on the handle value i get the retrun value
> > if handle is MONTH  it sends only month as date diff
> > if handle is null or nothing
> > it gives the date diff as  "YEAR # MONTH # DAY"
> > in front end i just split # and i got year , month and days as date diff
> >
> > --
> > Rakesh Hendre,
> > Sr. Software Architect
> > Brilliance Software Systems.http://www.brilliancesoftwares.com/
> > Mob : 9960001862
>



-- 
Rakesh Hendre,
Sr. Software Architect
Brilliance Software Systems.
http://www.brilliancesoftwares.com/
Mob : 9960001862

Reply via email to