Home » SQL & PL/SQL » SQL & PL/SQL » round function in dates
round function in dates [message #281693] Mon, 19 November 2007 00:58 Go to next message
swathikota
Messages: 3
Registered: October 2007
Location: INDIA
Junior Member
can the round and trunc functions in date be used only with sysdate ?
when i use them with a date in dd-mon-rr format,i get an error saying invalid number.
Re: round function in dates [message #281694 is a reply to message #281693] Mon, 19 November 2007 00:59 Go to previous messageGo to next message
Maaher
Messages: 7062
Registered: December 2001
Senior Member
Show us an example.

MHE
Re: round function in dates [message #281718 is a reply to message #281694] Mon, 19 November 2007 01:40 Go to previous messageGo to next message
Littlefoot
Messages: 20901
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
You are probably truncating (or rounding) a STRING instead of a DATE. I guess that TO_DATE might do the job.
Re: round function in dates [message #281735 is a reply to message #281694] Mon, 19 November 2007 03:04 Go to previous messageGo to next message
swathikota
Messages: 3
Registered: October 2007
Location: INDIA
Junior Member
select round(18-nov-07','month') from dual;
Re: round function in dates [message #281736 is a reply to message #281735] Mon, 19 November 2007 03:05 Go to previous messageGo to next message
ThomasG
Messages: 3189
Registered: April 2005
Location: Heilbronn, Germany
Senior Member
Littlefoot was right, it seems.
Re: round function in dates [message #281737 is a reply to message #281693] Mon, 19 November 2007 03:06 Go to previous messageGo to next message
Theracersman
Messages: 28
Registered: November 2007
Location: Indonesia
Junior Member

select trunc(sysdate) from dual;
Re: round function in dates [message #281739 is a reply to message #281735] Mon, 19 November 2007 03:10 Go to previous messageGo to next message
Theracersman
Messages: 28
Registered: November 2007
Location: Indonesia
Junior Member

i try your sql.
but i get error.that is invalid statement
Re: round function in dates [message #281740 is a reply to message #281737] Mon, 19 November 2007 03:11 Go to previous messageGo to next message
JRowbottom
Messages: 5933
Registered: June 2006
Location: Sunny North Yorkshire, ho...
Senior Member
Try
select round(to_date('18-nov-07','dd-mon-rr'),'month') from dual;

Re: round function in dates [message #281742 is a reply to message #281740] Mon, 19 November 2007 03:15 Go to previous messageGo to next message
swathikota
Messages: 3
Registered: October 2007
Location: INDIA
Junior Member
thank you.it's working that way.
Re: round function in dates [message #281750 is a reply to message #281693] Mon, 19 November 2007 03:25 Go to previous messageGo to next message
rajavu1
Messages: 1574
Registered: May 2005
Location: Bangalore , India
Senior Member

You can refer this link for more details on other functions ( May be One of the simplest description and explanation for the beginners )

Thumbs Up
rajuvan

[Updated on: Mon, 19 November 2007 03:25]

Report message to a moderator

Re: round function in dates [message #281752 is a reply to message #281742] Mon, 19 November 2007 03:28 Go to previous message
Theracersman
Messages: 28
Registered: November 2007
Location: Indonesia
Junior Member

congratulation...Very Happy
Previous Topic: Select rows with non zero values
Next Topic: passing array to function
Goto Forum:
  


Current Time: Sat Dec 10 03:25:00 CST 2016

Total time taken to generate the page: 0.05208 seconds