We're a community of 1076K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,075,886 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

How to find different between current time and time in database?

HI there,

I am doing my internship with accenture and i got my first assignment.

Basically i first thing with this task is i need to find way to modify the query so that it will pull only the data that has existed/activated more than one hour. This is the complete query :

select account_no, unixts_to_date(created_t), poid_id0, state_flag from
(
SELECT a.account_no, m.poid_id0, m.state_flag, c.created_t, row_number() OVER (PARTITION BY c.account_obj_id0 ORDER BY c.created_t DESC) rnk
FROM pone_bt_prod_inst_t m, pone_act_inst_t c, account_t a
WHERE m.state_flag IN ('0', '4', '5', '6', '7')
AND a.poid_id0 = m.account_obj_id0
AND c.prod_inst_id_id0 = m.poid_id0
AND m.service_type = '/service/ip/wimax'
AND m.entity_type = 'Plan'
AND c.state_flag NOT IN ('1', '2', '14')
ORDER BY created_t ASC
)
WHERE rnk = 1
UNION ALL
SELECT account_no, unixts_to_date(created_t), poid_id0, state_flag FROM
(
SELECT a.account_no, m.poid_id0, m.state_flag, c.created_t, row_number() OVER (PARTITION BY c.account_obj_id0 ORDER BY c.created_t DESC) rnk
FROM pone_bt_prod_inst_t m, pone_act_inst_t c, account_t a
WHERE m.state_flag IN ('16', '17', '18')
AND a.poid_id0 = m.account_obj_id0
AND c.prod_inst_id_id0 = m.poid_id0
AND m.service_type = '/service/ip/wimax'
AND m.entity_type = 'Deal'
AND c.state_flag NOT IN ('1', '2', '14')
ORDER BY created_t ASC
)
WHERE rnk = 1;

I show you the query so that you could grab the whole figure how the database looks like just in case you want to.
Anyway, from that query, I tr to play with it and I am trying to get the difference between the current time with the time in the created_t column.
As far as i got, this is the query :

SELECT TO_CHAR( unixts_to_date(created_t), 'SSSSS' )
FROM pone_bt_prod_inst_t 
WHERE ( TO_CHAR( SYSDATE, 'SSSSS' ) - TO_CHAR( unixts_to_date(created_t), 'SSSSS' ) ) > 3600;

I dont know whats wrong but it gave me the continous looping of "time" for the output.. And i know that the " 3600" is wrong, but may i know what the number i should put there as the comparison? because i want to output only data than has generated more than 1 hour, but still i dont know what format that original unix system used T___T What i mean is that, when i run the query of SELECT created_t FROM pone_bt_prod_inst_t; , it will output the time like this 1212640384 , so what is it actually?

thank you in advance for helping..

3
Contributors
3
Replies
2 Days
Discussion Span
11 Months Ago
Last Updated
4
Views
samsons17
Posting Whiz in Training
246 posts since Oct 2009
Reputation Points: 6
Solved Threads: 1
Skill Endorsements: 0

hey buddy.....
there is litte bit diffrence in that code ....first tell me which database software are you using??

ssuet
Newbie Poster
1 post since Jun 2012
Reputation Points: 0
Solved Threads: 0
Skill Endorsements: 0
urtrivedi
Posting Virtuoso
1,714 posts since Dec 2008
Reputation Points: 299
Solved Threads: 362
Skill Endorsements: 24

ssuet , i am using oracle database

samsons17
Posting Whiz in Training
246 posts since Oct 2009
Reputation Points: 6
Solved Threads: 1
Skill Endorsements: 0

This article has been dead for over three months: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
 
© 2013 DaniWeb® LLC
Page rendered in 0.0790 seconds using 2.67MB