• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 157
  • Last Modified:

Select records based on time

I need to be able to do a select statement for all records that are made where they have been updated within 45 minutes prior to a input time.

declare dt datetime
set dt =  2009-04-08 10:58
select memberID, LastName where lastLogin > 45 minutes prior to dt and lastLogin <=  dt
1 Solution
declare @dt datetime
set @dt =  '2009-04-08 10:58'
select memberID, LastName
where lastLogin > dateadd(n, -45, @dt) and
lastLogin <=  @dt
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Train for your Pen Testing Engineer Certification

Enroll today in this bundle of courses to gain experience in the logistics of pen testing, Linux fundamentals, vulnerability assessments, detecting live systems, and more! This series, valued at $3,000, is free for Premium members, Team Accounts, and Qualified Experts.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now