Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: Computed Field


This question is answered.


Permlink Replies: 3 - Last Post: Apr 14, 2018 6:08 PM Last Post By: Sriram Balasubr...
Melissa Torn

Posts: 143
Registered: 4/30/09
Computed Field  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Apr 9, 2018 12:45 AM
I'm trying to create a computed field which shows Year & Month
like : 2018/04
I created a computed field in my table and wrote below
code for the computed field
EXTRACT(YEAR FROM TDATE)+'/'+EXTRACT(MONTH FROM TDATE)
I'm getting Expression not supported error msg.

Thank You
Jeff Overcash (...

Posts: 1,529
Registered: 9/23/99
Re: Computed Field
Correct
Click to report abuse...   Click to reply to this thread Reply
  Posted: Apr 9, 2018 1:39 AM   in response to: Melissa Torn in response to: Melissa Torn
On 4/9/2018 3:45 AM, Melissa Torn wrote:
I'm trying to create a computed field which shows Year & Month
like : 2018/04
I created a computed field in my table and wrote below
code for the computed field
EXTRACT(YEAR FROM TDATE)+'/'+EXTRACT(MONTH FROM TDATE)
I'm getting Expression not supported error msg.

Thank You

Try casting the results from the Extracts to VarChars. Extract returns numbers
not strings IIRC.

--
Jeff Overcash (TeamB)
(Please do not email me directly unless asked. Thank You)
Learning is finding out what you already know. Doing is demonstrating that you
know it. Teaching is reminding others that they know it as well as you. We are
all leaners, doers, teachers. (R Bach)
quinn wildman

Posts: 156
Registered: 4/20/07
Re: Computed Field  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Apr 9, 2018 10:11 AM   in response to: Melissa Torn in response to: Melissa Torn
In SQL, concatenation is done via ||, not +. That is at least part of
your problem.

Melissa Torn wrote:
I'm trying to create a computed field which shows Year & Month
like : 2018/04
I created a computed field in my table and wrote below
code for the computed field
EXTRACT(YEAR FROM TDATE)+'/'+EXTRACT(MONTH FROM TDATE)
I'm getting Expression not supported error msg.

Thank You

---
This email has been checked for viruses by AVG.
http://www.avg.com
Sriram Balasubr...

Posts: 132
Registered: 10/19/99
Re: Computed Field  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Apr 14, 2018 6:08 PM   in response to: Melissa Torn in response to: Melissa Torn
Quinn is correct. This works for me...

select extract(year from current_date) || '/' || extract(month from current_date) from rdb$database;

Melissa Torn wrote:
I'm trying to create a computed field which shows Year & Month
like : 2018/04
I created a computed field in my table and wrote below
code for the computed field
EXTRACT(YEAR FROM TDATE)+'/'+EXTRACT(MONTH FROM TDATE)
I'm getting Expression not supported error msg.

Thank You
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02