Home » Developer & Programmer » Reports & Discoverer » can i use char for date return ?
can i use char for date return ? [message #626368] Mon, 27 October 2014 07:08 Go to next message
mist598
Messages: 1191
Registered: February 2013
Location: Hyderabad
Senior Member
Hi all,

function XXC_MESSGE return char
is
begin
  If AB > 0 then 
       return trunc(sysdate) -nvl(18,0);
  end if;
  return null;
end;

It will return Date and i have written char as return is this correct?
Re: can i use char for date return ? [message #626373 is a reply to message #626368] Mon, 27 October 2014 07:23 Go to previous messageGo to next message
cookiemonster
Messages: 13895
Registered: September 2008
Location: Rainy Manchester
Senior Member
It'll implicitly convert the date to a char using the sessions default format.
It'll work, but really you should add a to_char to make it clear.
And if you want the date to be in a particular format regardless of the sessions default datae format then you need to add the appropriate format mask.
Re: can i use char for date return ? [message #626375 is a reply to message #626373] Mon, 27 October 2014 07:28 Go to previous messageGo to next message
mist598
Messages: 1191
Registered: February 2013
Location: Hyderabad
Senior Member
Thanks for reply cookiemonster.. Smile
select to_char(trunc(sysdate), 'DD-MON-YYYY')-nvl(18,0) from dual

This one?
Re: can i use char for date return ? [message #626376 is a reply to message #626375] Mon, 27 October 2014 07:29 Go to previous messageGo to next message
cookiemonster
Messages: 13895
Registered: September 2008
Location: Rainy Manchester
Senior Member
You could have tried running it first.
You can't substract a number from a string.
Re: can i use char for date return ? [message #626377 is a reply to message #626376] Mon, 27 October 2014 07:36 Go to previous messageGo to next message
mist598
Messages: 1191
Registered: February 2013
Location: Hyderabad
Senior Member
Quote:
You could have tried running it first.

Yes getting an error..
Quote:
It'll work, but really you should add a to_char to make it clear.

can you please at which place to add to_char ?
Re: can i use char for date return ? [message #626379 is a reply to message #626377] Mon, 27 October 2014 07:46 Go to previous messageGo to next message
cookiemonster
Messages: 13895
Registered: September 2008
Location: Rainy Manchester
Senior Member
You need to to_char the date after you've done the subtraction.
Give it a try.
Re: can i use char for date return ? [message #626390 is a reply to message #626379] Mon, 27 October 2014 09:27 Go to previous messageGo to next message
mist598
Messages: 1191
Registered: February 2013
Location: Hyderabad
Senior Member
Hi
function CF_OC Formula return Char is
begin
  
  If :cf_Qty > 0 then
  	 return ('TOpen WO Qty: ' || :cf_WO_Qty);
  else
  	 return null;
  end if;
  
end;

cf_Qty returns number and is this correct code?
Re: can i use char for date return ? [message #626398 is a reply to message #626390] Mon, 27 October 2014 10:16 Go to previous messageGo to next message
cookiemonster
Messages: 13895
Registered: September 2008
Location: Rainy Manchester
Senior Member
What's cf_WO_qty?
Re: can i use char for date return ? [message #626407 is a reply to message #626398] Mon, 27 October 2014 12:31 Go to previous messageGo to next message
Littlefoot
Messages: 21612
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
What does this question have to do with the original question? Besides, I didn't see you (mist598) posting correct code for it yet.
Re: can i use char for date return ? [message #626441 is a reply to message #626407] Mon, 27 October 2014 22:56 Go to previous messageGo to next message
mist598
Messages: 1191
Registered: February 2013
Location: Hyderabad
Senior Member
Quote:
What's cf_WO_qty?

It returns number
Sorry for mistaken
This is original Code
function CF_OC Formula return Char is
begin
  
  If :cf_Qty > 0 then
  	 return ('TOpen Qty: ' || :cf_Qty );-->Changed!!
  else
  	 return null;
  end if;
  
end;
Re: can i use char for date return ? [message #626444 is a reply to message #626441] Tue, 28 October 2014 01:08 Go to previous messageGo to next message
Littlefoot
Messages: 21612
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
So, what is the question? Will this work? Did you try it? What happened?

You still didn't answer my previous question.
Re: can i use char for date return ? [message #626462 is a reply to message #626444] Tue, 28 October 2014 04:18 Go to previous message
cookiemonster
Messages: 13895
Registered: September 2008
Location: Rainy Manchester
Senior Member
It's same as with a date.
Oracle will implicitly convert it to a char using the sessions default number format.
You should use to_char for clarity and if you want a particular format you must supply the correct format mask.
Previous Topic: create a simple report
Next Topic: REP-0820 cannot import image
Goto Forum:
  


Current Time: Sun Oct 25 23:52:02 CDT 2020