DataBase/SQL

날짜와 날짜 사이의 날 모두 구하기

조심이 2008. 7. 24. 10:41
반응형
 

CREATE PROCEDURE PRO_IMSI999

AS

BEGIN

  /* Procedure body */

  create table #imsi ( enter_dt char(8) )

  declare @ymd char(8)


  select @ymd = '20071231'


  while @ymd < '20080501'

  begin

    select @ymd = CONVERT(CHAR(8),DATEADD( dd, 1, @ymd ),112)

   insert into #imsi ( enter_dt ) values ( @ymd )

  end

  select * from #imsi


  drop table #imsi

  

END


==============================


 

CREATE PROCEDURE PRO_IMSI999

AS

BEGIN

  /* Procedure body */

  create table #imsi ( enter_dt datetime )

  declare @ymd datetime


  select @ymd = '2007-12-31'


  while @ymd < '2008-05-01'

  begin

    select @ymd = DATEADD( dd, 1, @ymd )

   insert into #imsi ( enter_dt ) values ( @ymd )

  end

  select * from #imsi


  drop table #imsi

  

END



반응형