date format in SQL query [message #373023] |
Fri, 23 March 2001 09:00 |
Prapoorna
Messages: 6 Registered: October 2000
|
Junior Member |
|
|
Can u please let me know the difference in using to_date function and the trunc function for date columns in a SQL query
I have given two similar queries once using to_date and another time using trunc and the ouptput it gives is different.
Query:
select count(*), to_date(timein, 'DD-MON-YY') from usersessions where to_date(timein, 'DD-MON-YY') >= '15-OCT-98' group by to_date(timein, 'DD-MON_YY')
This gives me the correct output but when i give the same query using trunc (saying trunc(timein) ) instead of to_date it gives 'no rows selected'....
I would appeciate any help regarding this..
Thank You......
|
|
|
|
Re: date format in SQL query [message #373061 is a reply to message #373023] |
Sun, 25 March 2001 04:55 |
Narendra
Messages: 10 Registered: March 2001
|
Junior Member |
|
|
to_date function is used to convert a string in
date format TO date data type.
eg. where lastin >= to_date('01-JAN-2001','DD-MON-YYYY')
here lastin is a date field in table.
trunc function is used to eliminate time part of date.
|
|
|