ColdFusion Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreColdFusion Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here
  #1  
Old March 15th, 2004, 01:31 PM
tech-writer tech-writer is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2004
Posts: 40 tech-writer User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 59 m 9 sec
Reputation Power: 5
Screwy date output from Oracle table

I am getting funky data on my timestamp output. Using SYSDATE on the insert statement with an oracle db:

TO_CHAR(qmb.DATE_CREATED,'MM-DD-YYYY HH24:MM') date_created

This gets me a time of 14:03, or sometimes 04:03, regardless of the actual time. Do I need some kind of format definition in the insert statement?

Anyone have any ideas on this?

Last edited by tech-writer : March 15th, 2004 at 01:48 PM. Reason: supplying more data

Reply With Quote
  #2  
Old March 15th, 2004, 02:01 PM
kiteless kiteless is offline
Moderator
Dev Shed Loyal (3000 - 3499 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 3,480 kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 3 Days 17 h 33 m 17 sec
Reputation Power: 42
Are you saying the time that is actually being stored in the database is wrong, or it is wrong when you pull it out and use to_char() on it?

Reply With Quote
  #3  
Old March 15th, 2004, 03:12 PM
tech-writer tech-writer is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2004
Posts: 40 tech-writer User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 59 m 9 sec
Reputation Power: 5
Quote:
Originally Posted by kiteless
Are you saying the time that is actually being stored in the database is wrong, or it is wrong when you pull it out and use to_char() on it?


It seems to be storing the hours correctly. But the minutes always come out as "03" In viewing the db in TOAD, the time values is shown as a "0" ir a "1"

Reply With Quote
  #4  
Old March 15th, 2004, 05:07 PM
kiteless kiteless is offline
Moderator
Dev Shed Loyal (3000 - 3499 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 3,480 kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 3 Days 17 h 33 m 17 sec
Reputation Power: 42
So the problem is really in how you are inserting the date/time value into the table...CF is just reading back what is already stored.

How are you doing the insert of the date/time field?

Reply With Quote
  #5  
Old March 16th, 2004, 08:11 AM
tech-writer tech-writer is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2004
Posts: 40 tech-writer User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 59 m 9 sec
Reputation Power: 5
Quote:
Originally Posted by kiteless
So the problem is really in how you are inserting the date/time value into the table...CF is just reading back what is already stored.

How are you doing the insert of the date/time field?


insert into QMB values ('','','SYSDATE','')

Reply With Quote
  #6  
Old March 16th, 2004, 10:41 AM
kiteless kiteless is offline
Moderator
Dev Shed Loyal (3000 - 3499 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 3,480 kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 3 Days 17 h 33 m 17 sec
Reputation Power: 42
Shouldn't it be:

insert into QMB values ('','',SYSDATE)

which would insert a comma into the first column and the sysdate into the second column.

Can you confirm that the column that sysdate is going into is a date/time field?

Reply With Quote
  #7  
Old March 16th, 2004, 11:26 AM
tech-writer tech-writer is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2004
Posts: 40 tech-writer User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 59 m 9 sec
Reputation Power: 5
Quote:
Originally Posted by kiteless
Shouldn't it be:

insert into QMB values ('','',SYSDATE)

which would insert a comma into the first column and the sysdate into the second column.

Can you confirm that the column that sysdate is going into is a date/time field?



Those were single quotes. The date is going into the correct field. The exact syntax being used is:

insert into qmb_record values('#RECORD_ID#'+1,'#user_id#','n',SYSDATE,'','#other_fields#')

Last edited by tech-writer : March 16th, 2004 at 11:39 AM.

Reply With Quote
  #8  
Old March 16th, 2004, 01:15 PM
kiteless kiteless is offline
Moderator
Dev Shed Loyal (3000 - 3499 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 3,480 kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 3 Days 17 h 33 m 17 sec
Reputation Power: 42
Only thing I can think of is, can you confirm that the data type of the field that is holding the date is of data type "date"?

If you run this, do you get a date with the proper time component?

select sysdate from dual

Reply With Quote
  #9  
Old March 17th, 2004, 07:57 AM
tech-writer tech-writer is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2004
Posts: 40 tech-writer User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 59 m 9 sec
Reputation Power: 5
The datatype for the Oracle field is "timestamp"

TOAD doesn't seem to know how to handle the query you said to try.

Reply With Quote
  #10  
Old March 17th, 2004, 09:15 AM
kiteless kiteless is offline
Moderator
Dev Shed Loyal (3000 - 3499 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 3,480 kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 3 Days 17 h 33 m 17 sec
Reputation Power: 42
Timestamp is a data type specifically for storing extremely precise times, like down to a millionth of a second. This might be part of the problem, if you only want time to the second, a date field should be fine.

select sysdate from dual

simply selects the system time from the system's virtual table "dual". This should not be a problem...my copy of TOAD runs this query fine. If that doesn't work there may be other issues with your Oracle or TOAD configuration.

Reply With Quote
  #11  
Old March 19th, 2004, 08:33 AM
tech-writer tech-writer is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2004
Posts: 40 tech-writer User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 59 m 9 sec
Reputation Power: 5
Seemed the problem was in the output statement, I got that from somewhere here, but MM should have been MI for minutes.

But now I have another complexity for you on this:

How can I apply this formatting:

TO_CHAR(qmb.DATE_CREATED,'MM/DD/YYYY HH24:MI') date_created

To these parameters:

select max(DATE_CREATED) date_created from qmb


I need to maintain consistent format, but on one page I need to display the most recent timestamp for various groups of associated records.

Reply With Quote
  #12  
Old March 19th, 2004, 10:15 AM
kiteless kiteless is offline
Moderator
Dev Shed Loyal (3000 - 3499 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 3,480 kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 3 Days 17 h 33 m 17 sec
Reputation Power: 42
select TO_CHAR( max( DATE_CREATED ) ,'MM/DD/YYYY HH24:MI' ) as date_created
from qmb

Reply With Quote
  #13  
Old March 19th, 2004, 10:55 AM
tech-writer tech-writer is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2004
Posts: 40 tech-writer User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 59 m 9 sec
Reputation Power: 5
USing that I get the following error:

ORA-00937: not a single-group group function

Reply With Quote
  #14  
Old March 19th, 2004, 01:12 PM
kiteless kiteless is offline
Moderator
Dev Shed Loyal (3000 - 3499 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 3,480 kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 3 Days 17 h 33 m 17 sec
Reputation Power: 42
Do you have other fields in the query? I think you must, because this works fine on my local instance:

select TO_CHAR( max(CREATE_DATE),'MM/DD/YYYY HH24:MI') date_created from newsContent


If so, you'll need a GROUP BY clause.

Reply With Quote
  #15  
Old March 19th, 2004, 02:06 PM
tech-writer tech-writer is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2004
Posts: 40 tech-writer User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 59 m 9 sec
Reputation Power: 5
yes, as I say I am gathering data from 5 different tables. The existing query (which is quite long) doesn't generate errors. When I added that statement it would no longer run.

The statement runs fine by itself, but if that is just one of the datafields I need to query at once among several across multiple tables, it gets belligerant with me.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreColdFusion Development > Screwy date output from Oracle table


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump