X-Received: by 10.55.74.3 with SMTP id x3mr11501020qka.58.1508784173813; Mon, 23 Oct 2017 11:42:53 -0700 (PDT) X-Received: by 10.31.50.18 with SMTP id y18mr1031138vky.6.1508784173766; Mon, 23 Oct 2017 11:42:53 -0700 (PDT) Path: csiph.com!3.us.feeder.erje.net!feeder.erje.net!news.snarked.org!border2.nntp.dca1.giganews.com!border1.nntp.dca1.giganews.com!nntp.giganews.com!k31no1424507qta.1!news-out.google.com!r5ni1478qtc.1!nntp.google.com!z50no1428396qtj.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: microsoft.public.sqlserver.programming Date: Mon, 23 Oct 2017 11:42:53 -0700 (PDT) Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=216.234.125.194; posting-account=4nS5WwoAAACio8l9etd0ayIsc32V0GtK NNTP-Posting-Host: 216.234.125.194 User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: Subject: How to add a datetime column for a 24 hour period From: Mike Arney Injection-Date: Mon, 23 Oct 2017 18:42:53 +0000 Content-Type: text/plain; charset="UTF-8" Lines: 28 Xref: csiph.com microsoft.public.sqlserver.programming:31327 I have a MSSQL table with the following columns and data types: Topic -- nvarchar Payload -- numeric Timestamp -- datetime id -- int Here is some example data: Topic Payload Timestamp id STG/A/CycleStart 0 2017-10-23 15:37:56.697 1651 STG/A/CycleStart 0 2017-10-23 15:37:55.670 1650 STG/A/CycleStart 0 2017-10-23 15:37:55.193 1649 STG/A/CycleStart 0 2017-10-23 15:37:54.687 1648 The Timestamp column's default value is set to: (getutcdate()) I need to add the TIMESTAMP column for the last 24 hours where TOPIC = 'STG/A/CycleStart' and PAYLOAD = 1 I also need this time in seconds. Any help would be greatly appreciated. Thanks, Mike