Tuesday, March 27, 2012

Days between Two Dates.

Hi all,

I have a table in which I have two fields in my DB.

FromDate and ToDate.

Both are stored as Varchar(MAX).

I would like to have an SP which gives me the Days in Between them.

Regards,

Naveen.

try this:

selectdatediff(day,convert (datetime ,'07/05/2007'),convert (datetime ,'07/06/2007'))as [day diff]
|||

Hi addie,

what I want is an SP.

Regards,

Naveen

|||

ifexists (select *fromsysobjectswhere id =object_id ('sp_test'))drop proceduresp_testgocreate proceduresp_test@.start_datevarchar(20),@.end_datevarchar(20)asselectdatediff(day,convert (datetime , @.start_date),convert (datetime , @.end_date))as [day diff]

No comments:

Post a Comment