Link to home
Start Free TrialLog in
Avatar of Weller0123
Weller0123

asked on

Sysdate without time data

I need to pull sysdate as just a date (no time info)

What's the syntax?

Thanks,
Avatar of gattu007
gattu007

select sysdate from dual;


the above will not show u time.

select to_char(sysdate,'dd-mon-yyyy') from dual;
ASKER CERTIFIED SOLUTION
Avatar of jwahl
jwahl
Flag of Austria image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
select to_char(sysdate,'dd-mon-yyyy') from dual;

I think this is the best answer because this does not depend on the nls_date_format
setttings otherwise it depends on the format which has been set to nls_date_format.

select sysdate, trunc(sysdate), round(sysdate)
from dual;
-- will return date value according to the format set in nls_date_format. If you are
going to use this, then make sure that you have set your nls_date_format accordingly
which execludes time.

i agree with nav_kum_v, but it depends on what type you're expecting.
if you want DATE, you can use either

TRUNC(SYSDATE)
or
TO_DATE(TO_CHAR(SYSDATE, 'dd-mon-yyyy'), 'dd-mon-yyyy')

TO_CHAR(SYSDATE, 'dd-mon-yyyy') will return a VARCHAR2 string ...


You say you want to "pull" sysdate as <just a date (no time info)>
What are you going to do with it? If you just want to display it without any time shown, the default setting will likely manage that and, if not, the TO_CHAR(SYSDATE, 'dd-mon-yyyy') [or any other format mask without a time element] will accomplish that regardless of the default. If you are using it to compare with some other date datatype, the use of trunc(sysdate) will still have a time element (of midnight) so you may have to also use the trunc function on the "other date" to compare equality. Greater than and less than comparisons will also require some manipulation. Let us know of your intent.