Home » SQL & PL/SQL » SQL & PL/SQL » Date function
Date function [message #218034] Tue, 06 February 2007 08:58 Go to next message
a_developer
Messages: 194
Registered: January 2006
Senior Member
How do I get the date of the earliest Wednesday starting from sysdate (inclusive of Sysdate)???
Example today is Feb 6, 2007 and it's a Wendesday, so I should return 06-Feb-2007. But if today is 08-Feb-2007, I should return Feb 14 2007.
Can you please help me write the query?? Thanks.
Re: Date function [message #218038 is a reply to message #218034] Tue, 06 February 2007 09:09 Go to previous messageGo to next message
vamsi kasina
Messages: 2107
Registered: October 2003
Location: Riyadh, Saudi Arabia
Senior Member
I think you have heard next_day.
select decode(to_char(sysdate,'DY'),'WED',sysdate,next_day(sysdate,'WED')) from dual;
By
Vamsi
Re: Date function [message #218041 is a reply to message #218038] Tue, 06 February 2007 09:24 Go to previous messageGo to next message
a_developer
Messages: 194
Registered: January 2006
Senior Member
great! thanks!
Re: Date function [message #218067 is a reply to message #218034] Tue, 06 February 2007 12:21 Go to previous messageGo to next message
joy_division
Messages: 4644
Registered: February 2005
Location: East Coast USA
Senior Member
Not to be picky, but here on earth, February 6th, 2007 is a Tuesday. And I'm not sure Oracle functions will work if your weeks have 8 days in them (eg. Feb 6th and Feb 14th both being a Wednesday). Wink

[Updated on: Tue, 06 February 2007 12:24]

Report message to a moderator

Re: Date function [message #218124 is a reply to message #218067] Tue, 06 February 2007 22:50 Go to previous messageGo to next message
a_developer
Messages: 194
Registered: January 2006
Senior Member
Thanks for noticing that! I just lost touch with time.
By the way, I'm an earthling. Cool
Re: Date function [message #218137 is a reply to message #218124] Tue, 06 February 2007 23:42 Go to previous message
vamsi kasina
Messages: 2107
Registered: October 2003
Location: Riyadh, Saudi Arabia
Senior Member
./fa/1598/0/
I too didn't notice that../fa/1693/0/
By
Vamsi
Previous Topic: Merge error. bug or not?
Next Topic: Problem with the procedure which is using dbms_sql
Goto Forum:
  


Current Time: Fri Dec 09 21:34:01 CST 2016

Total time taken to generate the page: 0.09355 seconds