Don,

Basically yes.

Why are you not using "(curdate() - 1 YEAR)"?

Charles

-----Original Message-----
From: midrange-l-bounces@xxxxxxxxxxxx
[mailto:midrange-l-bounces@xxxxxxxxxxxx] On Behalf Of Don Cavaiani
Sent: Friday, November 16, 2007 1:51 PM
To: Midrange Systems Technical Discussion
Subject: RE: SQL Date Math

Elvis, does it have to go on EACH element of the date (as below)?

select * from bpcs405cdf/frt
where Dec( digits(Dec(year(curdate() - 365 days),4,0)) ||
digits(Dec(month(curdate() - 365 days),2,0)) ||

digits(Dec(day(curdate() - 365 days),2,0)) ) < refdt

-----Original Message-----
From: midrange-l-bounces@xxxxxxxxxxxx
[mailto:midrange-l-bounces@xxxxxxxxxxxx] On Behalf Of Elvis Budimlic
Sent: Friday, November 16, 2007 11:37 AM
To: 'Midrange Systems Technical Discussion'
Subject: RE: SQL Date Math

Don,

DB2 supports date arithmetic so something like CURDATE() - 30
DAYS ought
to work in your case.

Fact that you're using CURDATE built-in versus CURRENT_DATE special
register saves you from cross-midnight considerations as DB2 reads
time-of-day clock once per statement execution, which is exactly what
you want.

Elvis

Celebrating 10-Years of SQL Performance Excellence on IBM i5/OS and
OS/400 http://centerfieldtechnology.com/training.asp


-----Original Message-----
Subject: RE: SQL Date Math

Jim,

I'm liking method 2, and got it to work. Thanks! Now, how would I go
about adjusting the curdate - say to subtract 30 days from it before
using it in the comparison?

Don

-----Original Message-----
Subject: Re: SQL Date Math

Ok - hit send to early!

2nd way;
When Dec( digits(Dec(year(curdate()),4,0)) ||
digits(Dec(month(curdate()),2,0)) ||
digits(Dec(day(curdate()),2,0)) ) = refdta

This extracts the year, month and day from current date, then
puts them
back together and makes it into a number to compare with the field
refdta.

HTH

Jim


--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing
list To post a message email: MIDRANGE-L@xxxxxxxxxxxx To subscribe,
unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxx Before posting,
please take a
moment to review the archives at
http://archive.midrange.com/midrange-l.


--
This is the Midrange Systems Technical Discussion
(MIDRANGE-L) mailing list
To post a message email: MIDRANGE-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/midrange-l.




This e-mail transmission contains information that is intended to be confidential and privileged. If you receive this e-mail and you are not a named addressee you are hereby notified that you are not authorized to read, print, retain, copy or disseminate this communication without the consent of the sender and that doing so is prohibited and may be unlawful. Please reply to the message immediately by informing the sender that the message was misdirected. After replying, please delete and otherwise erase it and any attachments from your computer system. Your assistance in correcting this error is appreciated.


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.