Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sysdate format

Status
Not open for further replies.

Leon1977

IS-IT--Management
Jun 27, 2001
79
0
0
BG
Hi folks
I need to get todays date in PL/SQL
but sysdate returns date & time so I think I must truncate it somehow.
Can you show me the way to do this
 
Hi,

You get a timestamp format because the nls_date_format is defined with this format on the server side.

You have many solutions to solve your pb :

1/ select to_char(sysdate,'DD/MM/YYYY') from dual;
but it this return a varchar2 string.

2/ if you need the system date as a date :
select to_date(to_char(sysdate,'DD/MM/YYYY'),'DD/MM/YYYY') from dual;

NB : if you work on a indexed date field in a query using to_char(sysdate,...) or a to_date(to_char(sysdate,...)) , you will not used the index on the date field.

3/ Another solution is to alter your session on the client side (your SQL+ session):
alter session set nls_date_format ='DD/MM/YYYY'
and then call the PL/SQL commands.

Hope this help you.
Did02
 
thanx but I figured it out

trunc(sysdate,'dd')

Lazar
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top