Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Oracle current_date or sysdate without hours, minutes, seconds [duplicate]

Tags:

java

sql

oracle

Is there any way to get rid of the time of day when using current_date or sysdate. I'm trying to only the store the date as YYYY-MM-DD , but current_date is giving me YYYY-MM-DD HH:MM:SS:MS

Or when comparing the dates, it only compares the date and not the time would be just as good. Any help would be awesome, thanks.

like image 267
roverred Avatar asked Mar 30 '13 19:03

roverred


2 Answers

Maybe you should try

trunc(sysdate)

function.

like image 155
rusty Avatar answered Oct 09 '22 23:10

rusty


Rusty answered the part of your question regarding stripping the time portion. The part about incorporating the time when comparing dates is often done like this.

where YourDateField >= StartDate
and YourDateField < TheDayAfterEndDate

If you want to search on a specific date, StartDate and EndDate would be the same.

like image 32
Dan Bracuk Avatar answered Oct 10 '22 01:10

Dan Bracuk