473,397 Members | 2,084 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

DATE: valid expression

Hi NG,

are this actually valid expressions for DB2 v 7.2?

SELECT TABLE.ATTR1
FROM TABLE
WHERE
CURRENT DATE - 1 MONTH <= LAST_DAY(TABLE.ATTR2)

and

SELECT TABLE.ATTR1
FROM TABLE
WHERE
TABLE.ATTR2 <= TABLE.ATTR3

- ATTR2 and ATTR3 are DATE-columns...

Appreciate everyones help!!!

Thanks in Advance,

S.B.
Nov 12 '05 #1
6 4566
Stephan,
are this actually valid expressions for DB2 v 7.2?

are you testing us or the database?

Please state result.

Regards Rolf
Nov 12 '05 #2
"Stefan Bauer" <st***********@yahoo.de> wrote in message
news:64**************************@posting.google.c om...
Hi NG,

are this actually valid expressions for DB2 v 7.2?

SELECT TABLE.ATTR1
FROM TABLE
WHERE
CURRENT DATE - 1 MONTH <= LAST_DAY(TABLE.ATTR2)

and

SELECT TABLE.ATTR1
FROM TABLE
WHERE
TABLE.ATTR2 <= TABLE.ATTR3

- ATTR2 and ATTR3 are DATE-columns...

Appreciate everyones help!!!

Thanks in Advance,

S.B.


I have never heard of last_day function.

The second SQL statement is perfectly legal.
Nov 12 '05 #3
LAST_DAY is not a function in DB2 on Unix/Linux/Windows as far as we know.

Also, the table should not be called TABLE.

The second query looks okay.

BTW I defined the table as follows to test:
create table table1 (attr1 date, attr2 date, attr3 date)

Stefan Bauer wrote:
Hi NG,

are this actually valid expressions for DB2 v 7.2?

SELECT TABLE.ATTR1
FROM TABLE
WHERE
CURRENT DATE - 1 MONTH <= LAST_DAY(TABLE.ATTR2)

and

SELECT TABLE.ATTR1
FROM TABLE
WHERE
TABLE.ATTR2 <= TABLE.ATTR3

- ATTR2 and ATTR3 are DATE-columns...

Appreciate everyones help!!!

Thanks in Advance,

S.B.


Nov 12 '05 #4
Hi,

according to the IBM SQL Reference v. 7, LAST_DAY is a scalar
function, that returns a date that represents the last day of the
month, but only for UDB OS/390 and z/OS. :(

I found on the internet some expressions, that seems to provide the
same result. Unfortunately, I don't have a DB2-access, so there is no
possibility for me to prove, if they are correct:

(attr2 + 1 MONTH) - day(attr2 + 1 month) days

(attr2 + 1 MONTH) - day(attr2) days

(attr2 + 1 MONTH) - (1 DAY)

Thanks in Advance,

S.B.

Blair Adamache <ba*******@2muchspam.yahoo.com> wrote in message news:<bo**********@hanover.torolab.ibm.com>...
LAST_DAY is not a function in DB2 on Unix/Linux/Windows as far as we know.

Also, the table should not be called TABLE.

The second query looks okay.

BTW I defined the table as follows to test:
create table table1 (attr1 date, attr2 date, attr3 date)

Stefan Bauer wrote:
Hi NG,

are this actually valid expressions for DB2 v 7.2?

SELECT TABLE.ATTR1
FROM TABLE
WHERE
CURRENT DATE - 1 MONTH <= LAST_DAY(TABLE.ATTR2)

and

SELECT TABLE.ATTR1
FROM TABLE
WHERE
TABLE.ATTR2 <= TABLE.ATTR3

- ATTR2 and ATTR3 are DATE-columns...

Appreciate everyones help!!!

Thanks in Advance,

S.B.

Nov 12 '05 #5
st***********@yahoo.de (Stefan Bauer) wrote in message
Hi,

according to the IBM SQL Reference v. 7, LAST_DAY is a scalar
function, that returns a date that represents the last day of the
month, but only for UDB OS/390 and z/OS. :(

I found on the internet some expressions, that seems to provide the
same result. Unfortunately, I don't have a DB2-access, so there is no
possibility for me to prove, if they are correct:

(attr2 + 1 MONTH) - day(attr2 + 1 month) days Seems OK.

(attr2 + 1 MONTH) - day(attr2) days NG.
If attr2 is 2003-01-30, the expression will return 2003-01-29.

(attr2 + 1 MONTH) - (1 DAY)

NG.
Nov 12 '05 #6
Thank you! :-)

:-)

S.B.

to*****@jp.ibm.com (Tokunaga T.) wrote in message news:<81*************************@posting.google.c om>...
st***********@yahoo.de (Stefan Bauer) wrote in message
Hi,

according to the IBM SQL Reference v. 7, LAST_DAY is a scalar
function, that returns a date that represents the last day of the
month, but only for UDB OS/390 and z/OS. :(

I found on the internet some expressions, that seems to provide the
same result. Unfortunately, I don't have a DB2-access, so there is no
possibility for me to prove, if they are correct:

(attr2 + 1 MONTH) - day(attr2 + 1 month) days

Seems OK.

(attr2 + 1 MONTH) - day(attr2) days

NG.
If attr2 is 2003-01-30, the expression will return 2003-01-29.

(attr2 + 1 MONTH) - (1 DAY)

NG.

Nov 12 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Gord | last post by:
Hello, VB6 accepts Date and Time values as 'Date'. I'm trying to verify entry into a database I'm creating by verifying that an appropriate Date or Time value has been entered. Using built-in...
2
by: androtech | last post by:
Hello, I'm looking for a function that returns a date range for a specified week number of the year. I'm not able to find functions like this anywhere. Any pointers/help would be much...
2
by: Ian | last post by:
I would like to have some validation on a date field. The date format is dd/mm which is used for our financial year end. I suppose I need also consider leap years. Please can you shed some light on...
1
by: Ken | last post by:
I wrote a function to use in queries that takes a date and adds or subtracts a certain length time and then returns the new value. There are times when my function needs to return Null values. ...
17
by: Petyr David | last post by:
Just looking for the simplest. right now my perl script returns an error messge to the user if the date string is invalid. would like to do this before accessing the server. TX
1
by: Beckster6701 | last post by:
I have a MSAccess database that is linked to a SQL server. I cannot change the SQL server datatype as I am not the only one that uses the database. I'm trying to convert the text field to a valid...
4
by: SilentThunderer | last post by:
Hey folks, Let me start out by letting you know what I'm working with. I'm building an application in VB 2005 that is basically a userform that employees can use to "Clock in". The form...
28
Ericks
by: Ericks | last post by:
I want to highlight new data that has been entered in my database since a last meeting so it is easy to see in a subform’s table what info is new. In my database I have a table called...
5
by: shapper | last post by:
Hello, What is the Regex expression to validate a date time format as follows: dd-mm-yyyy hh:mm:ss An example: 20-10-2008 10:32:45
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.