Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 incremental time

Author  Topic 

JimL
SQL Slinging Yak Ranger

1537 Posts

Posted - 2003-03-26 : 16:43:41
I am setting up a scheduling table that Contains a Starttime and Endtime Fields I need to set this for 10 minute windows.

I set my Endtime Field with this.

UPDATE dbo.SCH_Calandar
SET EndTime = DATEADD(mi, 10, StartTime)

What I need to do now is create an append to a new record to the table with the Starttime = to the Endtime of the Previous record.

Any Ideas ????


byrmol
Shed Building SQL Farmer

1591 Posts

Posted - 2003-03-26 : 16:57:32
Insert SCH_Calandar (EndDate)
Select Dateadd(n,10,max(EndDate))
from SCH_Calandar


DavidM

"SQL-3 is an abomination.."
Go to Top of Page

JimL
SQL Slinging Yak Ranger

1537 Posts

Posted - 2003-03-26 : 17:38:43
Man am I stupid I came at this the wrong way. Thanks David


INSERT INTO dbo.SCH_Calandar
(StartTime)
SELECT DATEADD(n, 10, MAX(StartTime)) AS Expr1
FROM dbo.SCH_Calandar

UPDATE dbo.SCH_Calandar
SET EndTime = DATEADD(mi, 10, StartTime)

Go to Top of Page

simondeutsch
Aged Yak Warrior

547 Posts

Posted - 2003-03-26 : 22:27:26
You can put it in a loop to fill a day, if your Starttime column is an int.
DECLARE @StartTime INT
SET @StartTime = 0
WHILE @Startime < 144
BEGIN
INSERT SCH_Calendar(StartTime) VALUES(@startTime)
SET @StartTime = @startTime + 10
END
UPDATE SCh_Calendar SET Endtime = Startime + 10

If type is a date type, you will need to use dateadd.


Sarah Berger MCSD
Go to Top of Page
   

- Advertisement -