[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 189
  • Last Modified:

SQL Server compare datetime.

I need to compare the getdate() with a stored date in a field and if they're on the same date and the getdate() time is < the field time (hh:mm) execute a stored procedure.

Example the data field date and time is

2007-07-23 04:00:00.000

and getdate() is 2007-07-23 03:00:00.000

exec storeProc2
0
lrbrister
Asked:
lrbrister
1 Solution
 
Daniel WilsonCommented:
Declare @dt  DateTime

Select @dt = --whatever to grab the one you want

if getdate() < @dt AND Year(getdate()) = Year(@dt) and Month(getdate()) = Month(@dt) and Day(Getdate()) = Day(@dt)
Begin
  Exec StoredProc2
End
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

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