How do I add time to a datetime field with an indexing value?
My RDBMS is SQL Server 2008 R2.
I want to start at noon for a datetime field and for every record, take the base value of noon and add 15 seconds and set it for the record.
Example
Record 1: DateTime Value = '12:00:00 pm'
Record 2: DateTime Value = '12:00:15 pm'
Record 3: DateTime Value = '12:00:30 pm'
...n...
I toyed with a UPDATE query, but I couldn’t get it to index. I’m feeling this might require a function, but I’m not sure.
Ideas?
Respectfully,
Ray
Assuming that you have a table
YourTablewith adatetimecolumnValuethat you need to fill with a datetime value incremented by 15 seconds for each row. Here I use a column ID to specify the order of the rows.