Click here to Skip to main content
15,892,575 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I wanna to enter a time to the sql server database and begin calculating the time in recursive form
for example entering the time 05:23:34 and start computing until 00:00:00
someone help me please ?
Posted

1 solution

SQL
DECLARE @timeval AS DateTime
SET @timeval ='05:23:34'
DECLARE @Timetbl as table (tmval  datetime)

While @timeval <>'00:00:00'
 Begin
   INSERT INTO @Timetbl
   SELECT @timeval
   SET @timeval=DateAdd(ss,-1,@timeval)
 End

   INSERT INTO @Timetbl
   SELECT @timeval

select * from @Timetbl

SQL

 
Share this answer
 
Comments
EhsanGhanbari 1-Feb-12 13:53pm    
thanks a million ...
RDBurmon 1-Feb-12 13:58pm    
Welcome
Please accept and vote as well.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900