Computed column or another form for show the remaining day?

  • Hi everbody,

    I have a 'end time' column which data type "date", and i want to show how many days left until current time.

    Should i use computed column or another form and how can i do that?

    on SQL server 2008,

    thanks in advance.

  • create table #t (id int, Edate datetime)

    insert into #t (id ,Edate)

    select 1,getdate()-30 union all

    select 2,getdate()+30 union all

    select 3,getdate()+5 union all

    select 4,getdate()+26 union all

    select 5,getdate()

    select * from #t

    select *,datediff(day,getdate(),Edate)as Date from #t where Edate>getdate()

    drop table #t

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply