You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-user@db.apache.org by "Sebas.Panikulam" <Se...@wellsfargo.com> on 2008/11/25 22:38:13 UTC

Upcoming Birthdays Query for Derby database

Hi,
If anybody tried writing a query for Derby to fetch the upcoming Birthdays.
I am trying to modify the following query with respect to derby. The below
one will find the B'Days in the next 7 days.

SELECT * FROM [dbo].[tbl_EMPXYZ] 
WHERE MONTH(DOB) BETWEEN MONTH(GETDATE()) AND
MONTH(DATEADD(dd,20,GETDATE())) AND   
DAY(DOB) BETWEEN DAY(GETDATE()) AND DAY(DATEADD(dd,7,GETDATE()))

But I didn't find any function for adding date in derby(similar to DATEADD
in the above query). 

Does any one have a better approach or query?

Thanks
Sebas
-- 
View this message in context: http://www.nabble.com/Upcoming-Birthdays-Query-for-Derby-database-tp20690090p20690090.html
Sent from the Apache Derby Users mailing list archive at Nabble.com.


Re: Upcoming Birthdays Query for Derby database

Posted by "Dag H. Wanvik" <Da...@Sun.COM>.
"Sebas.Panikulam" <Se...@wellsfargo.com> writes:

> Hi,
> If anybody tried writing a query for Derby to fetch the upcoming Birthdays.
> I am trying to modify the following query with respect to derby. The below
> one will find the B'Days in the next 7 days.
>
> SELECT * FROM [dbo].[tbl_EMPXYZ] 
> WHERE MONTH(DOB) BETWEEN MONTH(GETDATE()) AND
> MONTH(DATEADD(dd,20,GETDATE())) AND   
> DAY(DOB) BETWEEN DAY(GETDATE()) AND DAY(DATEADD(dd,7,GETDATE()))
>
> But I didn't find any function for adding date in derby(similar to DATEADD
> in the above query). 

This link shows some ideas:

http://www.mailinglistarchive.com/derby-user@db.apache.org/msg02879.html

You could also use stored functions:

http://db.apache.org/derby/docs/10.4/ref/rrefcreatefunctionstatement.html

Thanks,
Dag