| | |
Converting datetime to int
Please support our MS SQL advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
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
Views: 1491 | Replies: 2
| Thread Tools | Search this Thread |
Tag cloud for MS SQL
"last age autogrowth business connectingtodatabaseinuse count cursor data database dateadd datediff datepart day" dbsize deadlock delete_trigger exploit getdate hack highperformancecomputing hpc hpcserver2008 ibm iis limit live loop maximum microsoft ms mssql multiple multithreading news number password permission position query reporting result security server services sets single source sql sql-injection sqlserver sqlserver2005 subtype supercomputing supertype tables uniqueid update view weekday





