| Author |
Topic  |
|
|
jun0
Starting Member
United Kingdom
24 Posts |
Posted - 03/08/2013 : 06:31:02
|
Hello,
I need to set up a stored procedure that runs each day and select data from a tale based on a specific date range e.g
lastoccurrence >= 'midnight the previous day' and lastoccurrence < 'midnight last night'
Obviously I can't hard code the dates in here, as that would really defeat the object of the stored procedure, so how do I go aout doing this so that the dates entered will always be between midnight he previous day and 12:00 last night? (sorry if the time range I need is a bit ambiguous, hope you understand what I'm after)..
thansk you!! |
|
|
visakh16
Very Important crosS Applying yaK Herder
India
47023 Posts |
Posted - 03/08/2013 : 06:36:43
|
use getdate() function for that
lastoccurrence >= dateadd(dd,datediff(dd,0,getdate()),-1) and lastoccurrence < dateadd(dd,datediff(dd,0,getdate()),0)
------------------------------------------------------------------------------------------------------ SQL Server MVP http://visakhm.blogspot.com/
|
 |
|
| |
Topic  |
|
|
|