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.
| 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_CalandarSET 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.." |
 |
|
|
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 Expr1FROM dbo.SCH_CalandarUPDATE dbo.SCH_CalandarSET EndTime = DATEADD(mi, 10, StartTime) |
 |
|
|
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 INTSET @StartTime = 0WHILE @Startime < 144 BEGIN INSERT SCH_Calendar(StartTime) VALUES(@startTime) SET @StartTime = @startTime + 10 ENDUPDATE SCh_Calendar SET Endtime = Startime + 10If type is a date type, you will need to use dateadd.Sarah Berger MCSD |
 |
|
|
|
|
|