Home » Developer & Programmer » Forms » date display in forms and oracle (forms 6i)
date display in forms and oracle [message #343835] Thu, 28 August 2008 05:51 Go to next message
varu123
Messages: 754
Registered: October 2007
Senior Member
Through forms I am enetering date in the database. The data type of DAte textitem is date.
In the database,after issuing alter session set nls_date_format command,
when i am querying date,it is displaying as

28-AUG-08 00:00:00

Why it is not recording the minute and seconds also?
I expected the output as
28-AUG-08 03:15:07

I changed the datatype from date to datetime but same result.

Re: date display in forms and oracle [message #343981 is a reply to message #343835] Thu, 28 August 2008 09:25 Go to previous messageGo to next message
saadatahmad
Messages: 452
Registered: March 2005
Location: Germany/Paderborn
Senior Member

hi,
Use a timer.
I'm attaching a form for your and other people's reference.
Run the following script.
create table test
(a date)
/


Download the attached form. Run the form and enter a date and save. It'll save date with time in database and then you can query your table.
SCOTT @ORCL> select * from test
  2  /

A
-------------------
28/08/2008 05:18:19

I hope you'll be able to apply this in your form.


regards,
Saadat Ahmad



[Updated on: Thu, 28 August 2008 09:27]

Report message to a moderator

Re: date display in forms and oracle [message #344084 is a reply to message #343835] Thu, 28 August 2008 13:59 Go to previous messageGo to next message
varu123
Messages: 754
Registered: October 2007
Senior Member
Is there any other way?
We have lots of forms where sysdate is entered as entry date.
Adding new text items to forms is not feasible.
Re: date display in forms and oracle [message #344261 is a reply to message #344084] Fri, 29 August 2008 04:32 Go to previous messageGo to next message
saadatahmad
Messages: 452
Registered: March 2005
Location: Germany/Paderborn
Senior Member

hi,
there may be many ways aroud if you don't want to create an item on your form. One is to define a global variable and use it to populate the time part.

Your code on When-New-Form-Instance trigger will be
:global.g_sys_time := null;
declare
	my_timer timer; 
begin 
	--Create a timer to trigger it every 1 sec(1000msec) 
	my_timer := create_timer('timer_sysdate',1000,repeat); 
end; 

When-Timer-Expired trigger code
:global.g_sys_time := to_char(sysdate,'hh:mi:ss');

When-Validate-Item code on your date item
declare
	v_date_time varchar2(30);
begin

	select to_char(nvl(:test.a, sysdate), 'dd/mm/rrrr')||' '||:global.g_sys_time
	into v_date_time
	from dual;
	
	select to_date(v_date_time, 'dd/mm/rrrr hh:mi:ss')
	into :test.a
	from dual;

end;

There are other ways around. You just have to think it.

Note :
If you are using system date in your forms date item then you need to set the initial property of the item only.

Set initial property to : $$datetime$$

In this case you don't need to write the triggers.


regards,
Saadat Ahmad

[Updated on: Fri, 29 August 2008 04:34]

Report message to a moderator

Re: date display in forms and oracle [message #344273 is a reply to message #344261] Fri, 29 August 2008 05:04 Go to previous messageGo to next message
sasipalarivattom
Messages: 118
Registered: June 2007
Location: Cochin ( INDIA )
Senior Member

Hi dear saadat,

Can you please tell me why this timer in the code?

can't we do it like this?

declare
	v_date_time varchar2(30);
begin

	select to_char(nvl(:test.a, sysdate), 'dd/mm/rrrr')
	into v_date_time
	from dual;
	v_date_time := v_date_time||' '||to_char(sysdate,'hh:mi:ss');

	select to_date(v_date_time, 'dd/mm/rrrr hh:mi:ss')
	into :test.a
	from dual;

end;



Regards Sasi...
Re: date display in forms and oracle [message #344317 is a reply to message #343835] Fri, 29 August 2008 06:41 Go to previous messageGo to next message
varu123
Messages: 754
Registered: October 2007
Senior Member
and there is no need of writing any code either.
I change the datatype from date to datetime in forms.
I verified in the database, the date does show in hh:mi:ss format.
Re: date display in forms and oracle [message #344651 is a reply to message #344273] Sun, 31 August 2008 09:28 Go to previous messageGo to next message
saadatahmad
Messages: 452
Registered: March 2005
Location: Germany/Paderborn
Senior Member

hi dear Sreepathi.

Yes we can do this way also. Timer was an extra thing which shows clock in the attached forms.
Quote:

@varu123
and there is no need of writing any code either.


what if you want to write a different date in your date field other than system date. In this case, form will attach midnight time with date item.

regards,
Saadat Ahmad
Re: date display in forms and oracle [message #344917 is a reply to message #344317] Mon, 01 September 2008 21:00 Go to previous message
djmartin
Messages: 10180
Registered: March 2005
Location: Canberra ACT Australia
Senior Member
Account Moderator
dhanya,

They really missed the obvious didn't they. Datetime versus date.

David
Previous Topic: Ora-12222 No such Protocol Adapter error
Next Topic: Installation Problem
Goto Forum:
  


Current Time: Fri Dec 09 15:54:15 CST 2016

Total time taken to generate the page: 0.43832 seconds