| | |
Converting datetime to int
Please support our MS SQL advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Sep 2006
Posts: 90
Reputation:
Solved Threads: 0
This set of code below shows all SQL Server Agent jobs that have failed for the date 200.03.29. The run_date column is an integer, but I want to run the code in such a way that the resultset is automatically generated for the day before the current date.
The code that works is below:
How can I change this so that run_date will get the equivalent integer value representing the day before the current date?
The code that works is below:
MS SQL Syntax (Toggle Plain Text)
SELECT [name] AS [Job Name],[server] AS [Server], step_id, step_name, [message] AS [Error], run_date AS [Date Started], run_time AS [Time Started], run_duration AS [Duration] FROM sysjobs JOIN sysjobhistory ON sysjobs.job_id = sysjobhistory.job_id WHERE run_date = 20090329 AND run_status = 0
How can I change this so that run_date will get the equivalent integer value representing the day before the current date?
•
•
Join Date: Sep 2006
Posts: 90
Reputation:
Solved Threads: 0
•
•
•
•
CONVERT (varchar, GETDATE() - 1, 112) will give you yesterdays date in that format
Thanks, but I wanted it as an INTEGER, not a varchar... the script references the sysjobhistory table in the msdb database, and, in that table, the run_date column is an integer.
![]() |
Similar Threads
- Error for UpdateQuery from Visual Studio 2008 (ASP.NET)
- indexing (C#)
Other Threads in the MS SQL Forum
- Previous Thread: How to add a computed field to a DAL table
- Next Thread: Help needed with UPDATE Trigger
| Thread Tools | Search this Thread |
Tag cloud for MS SQL
"last autogrowth business connectingtodatabaseinuse count cursor data database dateadd datepart day" dbsize deadlock delete_trigger getdate highperformancecomputing hpc hpcserver2008 ibm iis limit loop maximum microsoft ms mssql multiple multithreading news number permission position query reporting result server services sets single source sql sqlserver sqlserver2005 supercomputing tables uniqueid update view weekday





