Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
rob41
Yak Posting Veteran
67 Posts |
Posted - 2010-02-02 : 09:55:58
|
| I'm trying to create a table to show a select number of jobs that ran and have it display the latest date_created. I know how to get it to show a select number of jobs, i'm having trouble with getting it to show the date that I want to see. The jobs run every morning at midnight and I want to see only the jobs that were created every morning at 12 am, not the ones created in the past.please see code belowSELECT description ,step_name,date_createdINTO [TUESDAY_refresh]FROM msdb.dbo.sysjobs job JOIN msdb.dbo.sysjobsteps stepsON job.job_id = steps.job_idwhere [date_created] > [Current_date]-1 day Thanks as always :) |
|
|
harsh_athalye
Master Smack Fu Yak Hacker
5581 Posts |
Posted - 2010-02-02 : 10:01:22
|
How about this?where date_created >= dateadd(day, datediff(day, 0, getdate()), 0) EDIT: Thanks Visakh.Harsh Athalyehttp://www.letsgeek.net/ |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2010-02-02 : 10:06:12
|
| shouldnt that be?where date_created >=dateadd(day, datediff(day, 0, getdate()), 0) |
 |
|
|
rob41
Yak Posting Veteran
67 Posts |
Posted - 2010-02-02 : 10:12:31
|
| I inserted the code and it returned 0 records ? |
 |
|
|
harsh_athalye
Master Smack Fu Yak Hacker
5581 Posts |
Posted - 2010-02-02 : 10:19:17
|
| Could you post some sample data?Harsh Athalyehttp://www.letsgeek.net/ |
 |
|
|
|
|
|