mercredi 4 février 2015

How to add numeric value as seconds to a datetime field and report data in new column

I need to convert the ElapsedTime field into hours/minutes/seconds and add that to the creationtime field and have the results reported into a new column that I'll call EndTime. Here is the query I have to gather the data:



select ElapsedTime, ChannelUsed, documents.creationtime from historytrx (nolock) inner join history on historytrx.handle = history.handle inner join documents on history.owner = documents.handle inner join DocFiles on documents.docfiledba = docfiles.handle where creationtime > '2015-02-02 20:00:00.000' and creationtime < '2015-02-02 20:01:00.000' and RemoteServer = 'DMG4120-01668' and ElapsedTime != '0'


Here is the current output:



ElapsedTime ChannelUsed creationtime
1042 1 2015-02-02 20:00:03.000
27 35 2015-02-02 20:00:05.000
57 50 2015-02-02 20:00:05.000


Here is my desired output:



ElapsedTime ChannelUsed creationtime EndTime
1042 1 2015-02-02 20:00:03.000 2015-02-02 20:17:39.000
27 35 2015-02-02 20:00:05.000 2015-02-02 20:00:32.000
57 50 2015-02-02 20:00:05.000 2015-02-02 20:01:03.000


Thanks to everyone in advance for any assistance.


Aucun commentaire:

Enregistrer un commentaire