Justin
Justin

Reputation: 275

How Do I display current date and time in Toad for Oracle?

I have a sql statement that counts the units(cable boxes) that were refurbished (had damaged parts replaced) and total units(cable boxes that just went through refurb and had nothing replaced) and it's supposed to do this count regularly (every time a unit is processed the count). Can someone please help me? Thank you.

Justin

Heres my sql code so far:

SELECT COUNT(*) FROM cxadminn.repair_part
WHERE repair_type = 'REFURB' and created_date >?

Upvotes: 2

Views: 20881

Answers (3)

Gudinya
Gudinya

Reputation: 1

SELECT COUNT(*) FROM cxadminn.repair_part
WHERE repair_type = 'REFURB' and created_date > sysdate

or

created_date > to_date('01.01.11 01:01:01', 'dd.mm.yyyy hh:mi:ss')

Upvotes: 0

d5e5
d5e5

Reputation: 442

I think you want the current date and time when you run the query, which is not the same as created_date, right?

select COUNT(*), 
to_char(sysdate, 'Dy DD-Mon-YYYY HH24:MI:SS') as "Current Time"
FROM cxadminn.repair_part
WHERE repair_type = 'REFURB'

I removed the and created_date >? from the WHERE clause because it doesn't make sense to me, unless you can have items in your table whose created_date is in the future.

Upvotes: 1

user330315
user330315

Reputation:

SELECT COUNT(*) 
FROM cxadminn.repair_part
WHERE repair_type = 'REFURB' 
  and created_date > sysdate

To exclude the time that is part of any oracle DATE column, you would need to use this:

SELECT COUNT(*) 
FROM cxadminn.repair_part
WHERE repair_type = 'REFURB' 
  and trunc(created_date) > trunc(sysdate)

Upvotes: 2

Related Questions