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.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 creating a table to show latest refresh date

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 below

SELECT description ,step_name,date_created
INTO [TUESDAY_refresh]
FROM msdb.dbo.sysjobs job JOIN msdb.dbo.sysjobsteps steps
ON job.job_id = steps.job_id
where [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 Athalye
http://www.letsgeek.net/
Go to Top of Page

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)
Go to Top of Page

rob41
Yak Posting Veteran

67 Posts

Posted - 2010-02-02 : 10:12:31
I inserted the code and it returned 0 records ?
Go to Top of Page

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2010-02-02 : 10:19:17
Could you post some sample data?


Harsh Athalye
http://www.letsgeek.net/
Go to Top of Page
   

- Advertisement -