Results 1 to 7 of 7
Thread: Simple query about timestamps
-
07-30-2012, 11:44 AM #1
Simple query about timestamps
To meet an SLA I have a script for a client that is set up as follows.
Is there a way to specify 'TODAY' as opposed to the date format '2012-07-30'?
And yes I tried today and it did not work.
Thanks!
select cast((server_name) as char(10)) AS TSM_SERVER, cast((node_name) as char(20)) AS NODE_NAME,cast((schedule_name)as char(15)) AS Sched_Name,cast((status) as char(
) AS STATUS, count(*) as "3_DAY_COUNT" from EVENTS, status where (scheduled_start >= '2012-07-30')and (scheduled_start >=current_timestamp - 3 days) and (status='Failed' or status='Missed') and node_name is not NULL group by server_name, node_name,schedule_name, status having count(*)>=2 order by status, "3_DAY_COUNT" desc
-
07-30-2012, 12:01 PM #2Senior Member
- Join Date
- Dec 2004
- Location
- NC
- Posts
- 200
- Thanks
- 0
- Thanked 11 Times in 11 Posts
yes, current_date
"If we knew what it was we were doing, it would not be called research, would it?" -- Albert Einstein
-
07-30-2012, 12:09 PM #3
Gave that a shot in a couple different ways.
ANR2916E The SQL data types TIMESTAMP and DATE are incompatible for operator '>='.
|
..............................V................... .............
status where (scheduled_start >=current_date)and (scheduled_sta
ANS8001I Return code 3.
ANR2948E The value 'current_date' can not be assigned or converted to SQL data type TIMESTAMP.
|
........................V......................... .............
ere (scheduled_start >= 'current_date')and (scheduled_start >=c
ANS8001I Return code 26.
tsm: TSMSERVER>select cast((server_name) as char(10)) AS TSM_SERVER, cast((node_name) as char(20)) AS NODE_NAME,cast((sch
edule_name)as char(15)) AS Sched_Name,cast((status) as char(
) AS STATUS, count(*) as "3_DAY_COUNT" from EVENTS, status
where (scheduled_start >=current_timestamp - 3 days) and (status='Failed' or s
tatus='Missed') and node_name is not NULL group by server_name, node_name,schedule_name, status having count(*)>=2 order
by status, "3_DAY_COUNT" desc
ANR2034E SELECT: No match found using this criteria.
ANS8001I Return code 11.
Seemed to get the correct result with this query using current_timestamp and current_timestamp as current_date in both fields did not work either.
ThanksLast edited by etchingsj; 07-30-2012 at 12:16 PM. Reason: Had the same operator twice???
-
07-30-2012, 12:42 PM #4Senior Member
- Join Date
- Dec 2004
- Location
- NC
- Posts
- 200
- Thanks
- 0
- Thanked 11 Times in 11 Posts
You wcan't just compare a timestamp to a date, you need to use a function to convert the timestamp.
date(scheduled_start)=current_date"If we knew what it was we were doing, it would not be called research, would it?" -- Albert Einstein
-
07-30-2012, 03:34 PM #5
-
07-30-2012, 04:52 PM #6Senior Member
- Join Date
- Dec 2004
- Location
- NC
- Posts
- 200
- Thanks
- 0
- Thanked 11 Times in 11 Posts
Like this. Note I had to guess on the char() for status since I see an emoticon. I also used the "in" function near the end.
select cast((server_name) as char(10)) AS TSM_SERVER, \
cast((node_name) as char(20)) AS NODE_NAME, \
cast((schedule_name)as char(15)) AS Sched_Name, \
cast((status) as char(10)) AS STATUS, count(*) as "3_DAY_COUNT" \
from EVENTS, status where (date(scheduled_start)>=current_date - 3 days) \
and status in ('Failed','Missed') and node_name is not NULL \
group by server_name, node_name,schedule_name, status having count(*)>=2 \
order by status, "3_DAY_COUNT" desc"If we knew what it was we were doing, it would not be called research, would it?" -- Albert Einstein
-
07-30-2012, 05:35 PM #7
Similar Threads
-
A Very Simple Question ....??????? KB/S!!!
By fanna in forum Backup / Archive DiscussionReplies: 4Last Post: 10-22-2008, 08:24 AM -
Very simple SCHEDULE !!!!
By fanna in forum TDP/Application Layer BackupReplies: 14Last Post: 03-20-2008, 04:14 AM -
Simple SQL query into single-line output?
By kzw2zx in forum ScriptingReplies: 10Last Post: 02-13-2008, 03:21 PM -
simple macro q
By cabledguy2006 in forum ScriptingReplies: 4Last Post: 09-02-2007, 09:57 PM -
Please help..Simple question
By tsmnewbie in forum TSM Reporting & MonitoringReplies: 3Last Post: 06-23-2004, 12:17 PM


Reply With Quote
