first day of the year

hi
in oracle form , how i can return first day of the year for a given date
field name is : :BASIC_BLOCK.c_per
i found this function
SELECT TRUNC(to_date('17-DEC-2001'),'YEAR') "First Day" FROM Dual;
but it doesnt work when i replaced it like this
declare
begd date;
begin
SELECT to_date(:BASIC_BLOCK.c_per ,'Yyyy-mm-dd') into begd  FROM Dual;
NiceMan331Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

sdstuberCommented:
assuming :basic_block.c_per is a text field try this

SELECT trunc(to_date(:BASIC_BLOCK.c_per ,'yyyy-mm-dd'),'yyyy') into :begd  FROM Dual;

or

:begd := trunc(to_date(:BASIC_BLOCK.c_per ,'yyyy-mm-dd'),'yyyy');


if :basic_block.c_per is a date then you can simply do...


SELECT trunc(:BASIC_BLOCK.c_per) into :begd  FROM Dual;

or

:begd := trunc(:BASIC_BLOCK.c_per,'yyyy');

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
NiceMan331Author Commented:
:basic_block.c_per is a date field and formatted as 'yyyy-mm-dd'
that one doesnt work also
sdstuberCommented:
>>> :basic_block.c_per is a date field and formatted as 'yyyy-mm-dd'

no

a date does not have a format
text has a format.

>>> that one doesnt work also

I gave 4 options, which "one"  ?

and "doesn't work" in what way?
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

NiceMan331Author Commented:
i didnt see your update for the comment
this one now works
begd := trunc(:BASIC_BLOCK.c_per,'yyyy');

but in the query , it required to be formatted as : yyyy-mm-dd
the form doesnt accept it
sdstuberCommented:
in the form you are typing in text, that text must have a format,  and then the form converts the text  by that format into a date.
NiceMan331Author Commented:
So , what would be the formula looks like ?
sdstuberCommented:
You have it already, since :basic_block.c_per is a date


begd := trunc(:BASIC_BLOCK.c_per,'yyyy');
NiceMan331Author Commented:
begd := trunc(:BASIC_BLOCK.c_per,'yyyy');
doesnt work , it sent me error < ORA-00932
this one only works :
 to_date(''' || to_char(trunc(:BASIC_BLOCK.c_per,'yyyy'),'YYYY-MM-DD') || ''',''YYYY-MM-DD'')

Open in new window

i understand from you that date field doesn't required format , but it really doesn't work
, in sql it works , but in form no
NiceMan331Author Commented:
i accepted the solution as it works in sql-plus only
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Oracle Database

From novice to tech pro — start learning today.