Date comparison

View: New views
6 Messages — Rating Filter:   Alert me  

Date comparison

by Barry Rogen :: Rate this Message:

| View Threaded | Show Only this Message


We have been experiencing this quite a bit and am not sure why we are getting mis-comparisions.  Below is a simplified example of our issue

B$CHECK.855.SENT:  51:          IF ST.DATE # "" THEN
B$CHECK.855.SENT:  52:             IF ST.DATE < "12-31-11" THEN
B$CHECK.855.SENT:  53:                PRINT PL:"Date is less than  12-31-11...":

: ST.DATE/
STRING: T r L=8 `01-20-12'

We  have this issue with programs and with SELECT statements throughout. When you qualify a  date for this year to a date from 2011 it  screws up.


Barry Rogen
Senior Programmer/Analyst
PNY Technologies, Inc.
(973) 560-5327
brogen@...<mailto:brogen@...>

------------------------------------------------------------------------------------------------------------------------
        We are continually faced with great opportunities brilliantly disguised as insoluble problems.
                                                             John W Gardner
------------------------------------------------------------------------------------------------------------------------
 [http://thinkbeforeprinting.org/struct/signature-1.gif]




  ________________________________
NOT INTENDED AS A SUBSTITUTE FOR A WRITING
NOTHING IN THIS E-MAIL, IN ANY E-MAIL THREAD OF WHICH IT MAY BE A PART, OR IN ANY ATTACHMENTS THERETO, SHALL CONSTITUTE A BINDING CONTRACT, OR ANY CONTRACTUAL OBLIGATION BY PNY, OR ANY INTENT TO ENTER INTO ANY BINDING OBLIGATIONS, NOTWITHSTANDING ANY ENACTMENT OF THE UNIFORM ELECTRONIC TRANSACTIONS ACT, THE FEDERAL E-SIGN ACT, OR ANY OTHER STATE OR FEDERAL LAW OF SIMILAR SUBSTANCE OR EFFECT. THIS EMAIL MESSAGE, ITS CONTENTS AND ATTACHMENTS ARE NOT INTENDED TO REPRESENT AN OFFER OR ACCEPTANCE OF AN OFFER TO ENTER INTO A CONTRACT. NOTHING IN THIS E-MAIL, IN ANY E-MAIL THREAD OF WHICH IT MAY BE A PART, OR IN ANY ATTACHMENTS THERETO SHALL ALTER THIS DISCLAIMER.

This e-mail message from PNY Technologies, Inc. is for the sole use of the intended recipient(s) and may contain confidential and privileged information. Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipient, please contact the sender by reply e-mail and destroy all copies of the original message.

_______________________________________________
U2-Users mailing list
U2-Users@...
http://listserver.u2ug.org/mailman/listinfo/u2-users

Re: Date comparison

by Martin Phillips :: Rate this Message:

| View Threaded | Show Only this Message

Hi Barry,

Unless I am mis-understanding your example, you appear to be doing this
comparison using external format dates which is doomed to failure.

They will be compared as simple character strings, left to right, until a
difference is found. You need to do the comparison with an internal day
number.



Martin Phillips
Ladybridge Systems Ltd
17b Coldstream Lane, Hardingstone, Northampton NN4 6DB, England
+44 (0)1604-709200



-----Original Message-----
From: Barry Rogen
Sent: Tuesday, January 24, 2012 1:17 PM
To: U2 Users List (u2-users@...)
Subject: [U2] Date comparison


We have been experiencing this quite a bit and am not sure why we are
getting mis-comparisions.  Below is a simplified example of our issue

B$CHECK.855.SENT:  51:          IF ST.DATE # "" THEN
B$CHECK.855.SENT:  52:             IF ST.DATE < "12-31-11" THEN
B$CHECK.855.SENT:  53:                PRINT PL:"Date is less than
12-31-11...":

: ST.DATE/
STRING: T r L=8 `01-20-12'

We  have this issue with programs and with SELECT statements throughout.
When you qualify a  date for this year to a date from 2011 it  screws up.


Barry Rogen
Senior Programmer/Analyst
PNY Technologies, Inc.
(973) 560-5327
brogen@...<mailto:brogen@...>

------------------------------------------------------------------------------------------------------------------------
        We are continually faced with great opportunities brilliantly
disguised as insoluble problems.
                                                             John W Gardner
------------------------------------------------------------------------------------------------------------------------
[http://thinkbeforeprinting.org/struct/signature-1.gif]




  ________________________________
NOT INTENDED AS A SUBSTITUTE FOR A WRITING
NOTHING IN THIS E-MAIL, IN ANY E-MAIL THREAD OF WHICH IT MAY BE A PART, OR
IN ANY ATTACHMENTS THERETO, SHALL CONSTITUTE A BINDING CONTRACT, OR ANY
CONTRACTUAL OBLIGATION BY PNY, OR ANY INTENT TO ENTER INTO ANY BINDING
OBLIGATIONS, NOTWITHSTANDING ANY ENACTMENT OF THE UNIFORM ELECTRONIC
TRANSACTIONS ACT, THE FEDERAL E-SIGN ACT, OR ANY OTHER STATE OR FEDERAL LAW
OF SIMILAR SUBSTANCE OR EFFECT. THIS EMAIL MESSAGE, ITS CONTENTS AND
ATTACHMENTS ARE NOT INTENDED TO REPRESENT AN OFFER OR ACCEPTANCE OF AN OFFER
TO ENTER INTO A CONTRACT. NOTHING IN THIS E-MAIL, IN ANY E-MAIL THREAD OF
WHICH IT MAY BE A PART, OR IN ANY ATTACHMENTS THERETO SHALL ALTER THIS
DISCLAIMER.

This e-mail message from PNY Technologies, Inc. is for the sole use of the
intended recipient(s) and may contain confidential and privileged
information. Any unauthorized review, use, disclosure or distribution is
prohibited. If you are not the intended recipient, please contact the sender
by reply e-mail and destroy all copies of the original message.






_______________________________________________
U2-Users mailing list
U2-Users@...
http://listserver.u2ug.org/mailman/listinfo/u2-users 

_______________________________________________
U2-Users mailing list
U2-Users@...
http://listserver.u2ug.org/mailman/listinfo/u2-users

Re: Date comparison

by Israel, John R. :: Rate this Message:

| View Threaded | Show Only this Message

Isn't your 2nd line of code going to be doing a string comparison on the date, not a true date (number) comparison?

I always do an internal format comparison of dates.  If you need to do string comparisons, you d want them in YYYY-MM-DD format, but I advise against it.

John







John Israel
Senior ERP Developer

Dayton Superior Corporation
1125 Byers Rd  Miamisburg, OH 45342
Office: 937-866-0711 x44380
Fax: 937-865-9182

JohnIsrael@...

This message w/attachments (message) is intended solely for the use of the intended recipient(s) and may contain information that is privileged, confidential or proprietary. If you are not an intended recipient, please notify the sender, and then please delete and destroy all copies and attachments, and be advised that any review or dissemination of, or the taking of any action in reliance on, the information contained in or attached to this message is prohibited.




-----Original Message-----
From: u2-users-bounces@... [mailto:u2-users-bounces@...] On Behalf Of Barry Rogen
Sent: Tuesday, January 24, 2012 8:18 AM
To: U2 Users List (u2-users@...)
Subject: [U2] Date comparison


We have been experiencing this quite a bit and am not sure why we are getting mis-comparisions.  Below is a simplified example of our issue

B$CHECK.855.SENT:  51:          IF ST.DATE # "" THEN
B$CHECK.855.SENT:  52:             IF ST.DATE < "12-31-11" THEN
B$CHECK.855.SENT:  53:                PRINT PL:"Date is less than  12-31-11...":

: ST.DATE/
STRING: T r L=8 `01-20-12'

We  have this issue with programs and with SELECT statements throughout. When you qualify a  date for this year to a date from 2011 it  screws up.


Barry Rogen
Senior Programmer/Analyst
PNY Technologies, Inc.
(973) 560-5327
brogen@...<mailto:brogen@...>

------------------------------------------------------------------------------------------------------------------------
        We are continually faced with great opportunities brilliantly disguised as insoluble problems.
                                                             John W Gardner
------------------------------------------------------------------------------------------------------------------------
 [http://thinkbeforeprinting.org/struct/signature-1.gif]




  ________________________________
NOT INTENDED AS A SUBSTITUTE FOR A WRITING NOTHING IN THIS E-MAIL, IN ANY E-MAIL THREAD OF WHICH IT MAY BE A PART, OR IN ANY ATTACHMENTS THERETO, SHALL CONSTITUTE A BINDING CONTRACT, OR ANY CONTRACTUAL OBLIGATION BY PNY, OR ANY INTENT TO ENTER INTO ANY BINDING OBLIGATIONS, NOTWITHSTANDING ANY ENACTMENT OF THE UNIFORM ELECTRONIC TRANSACTIONS ACT, THE FEDERAL E-SIGN ACT, OR ANY OTHER STATE OR FEDERAL LAW OF SIMILAR SUBSTANCE OR EFFECT. THIS EMAIL MESSAGE, ITS CONTENTS AND ATTACHMENTS ARE NOT INTENDED TO REPRESENT AN OFFER OR ACCEPTANCE OF AN OFFER TO ENTER INTO A CONTRACT. NOTHING IN THIS E-MAIL, IN ANY E-MAIL THREAD OF WHICH IT MAY BE A PART, OR IN ANY ATTACHMENTS THERETO SHALL ALTER THIS DISCLAIMER.

This e-mail message from PNY Technologies, Inc. is for the sole use of the intended recipient(s) and may contain confidential and privileged information. Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipient, please contact the sender by reply e-mail and destroy all copies of the original message.
_______________________________________________
U2-Users mailing list
U2-Users@...
http://listserver.u2ug.org/mailman/listinfo/u2-users

Re: Date comparison

by David A. Green :: Rate this Message:

| View Threaded | Show Only this Message

Just adding the advice to make sure all your date dictionaries have Right
Justified formats.

David A. Green
(480) 813-1725
DAG Consulting


-----Original Message-----
From: u2-users-bounces@...
[mailto:u2-users-bounces@...] On Behalf Of Barry Rogen
Sent: Tuesday, January 24, 2012 6:18 AM
To: U2 Users List (u2-users@...)
Subject: [U2] Date comparison


We have been experiencing this quite a bit and am not sure why we are
getting mis-comparisions.  Below is a simplified example of our issue

B$CHECK.855.SENT:  51:          IF ST.DATE # "" THEN
B$CHECK.855.SENT:  52:             IF ST.DATE < "12-31-11" THEN
B$CHECK.855.SENT:  53:                PRINT PL:"Date is less than
12-31-11...":

: ST.DATE/
STRING: T r L=8 `01-20-12'

We  have this issue with programs and with SELECT statements throughout.
When you qualify a  date for this year to a date from 2011 it  screws up.


Barry Rogen
Senior Programmer/Analyst
PNY Technologies, Inc.
(973) 560-5327
brogen@...<mailto:brogen@...>

----------------------------------------------------------------------------
--------------------------------------------
        We are continually faced with great opportunities brilliantly
disguised as insoluble problems.
                                                             John W Gardner
----------------------------------------------------------------------------
--------------------------------------------
 [http://thinkbeforeprinting.org/struct/signature-1.gif]




  ________________________________
NOT INTENDED AS A SUBSTITUTE FOR A WRITING NOTHING IN THIS E-MAIL, IN ANY
E-MAIL THREAD OF WHICH IT MAY BE A PART, OR IN ANY ATTACHMENTS THERETO,
SHALL CONSTITUTE A BINDING CONTRACT, OR ANY CONTRACTUAL OBLIGATION BY PNY,
OR ANY INTENT TO ENTER INTO ANY BINDING OBLIGATIONS, NOTWITHSTANDING ANY
ENACTMENT OF THE UNIFORM ELECTRONIC TRANSACTIONS ACT, THE FEDERAL E-SIGN
ACT, OR ANY OTHER STATE OR FEDERAL LAW OF SIMILAR SUBSTANCE OR EFFECT. THIS
EMAIL MESSAGE, ITS CONTENTS AND ATTACHMENTS ARE NOT INTENDED TO REPRESENT AN
OFFER OR ACCEPTANCE OF AN OFFER TO ENTER INTO A CONTRACT. NOTHING IN THIS
E-MAIL, IN ANY E-MAIL THREAD OF WHICH IT MAY BE A PART, OR IN ANY
ATTACHMENTS THERETO SHALL ALTER THIS DISCLAIMER.

This e-mail message from PNY Technologies, Inc. is for the sole use of the
intended recipient(s) and may contain confidential and privileged
information. Any unauthorized review, use, disclosure or distribution is
prohibited. If you are not the intended recipient, please contact the sender
by reply e-mail and destroy all copies of the original message.

_______________________________________________
U2-Users mailing list
U2-Users@...
http://listserver.u2ug.org/mailman/listinfo/u2-users

Re: Date comparison

by WJhonson :: Rate this Message:

| View Threaded | Show Only this Message



 
The person who wrote
that line of code
must be
executed.

That's the only solution


_______________________________________________
U2-Users mailing list
U2-Users@...
http://listserver.u2ug.org/mailman/listinfo/u2-users

Re: Date comparison

by Ed Clark-3 :: Rate this Message:

| View Threaded | Show Only this Message

You should always work with dates/times/numbers in internal format and only convert them to external format for display.
Wherever ST.DATE came from, it should have been converted using ICONV:
  ST.DATE=ICONV(ST.DATE,"D")
and have a value of 16091 (assuming that the "12" means "2012" and not "1912"). The comparison would be
  IF ST.DATE < ICONV("12-31-2011","D") THEN

The actual data stored in  a file should be in internal format--never ever external.
When using query LIST/SELECT, make sure the dictionary is right justified and has a date conversion:

0001 D
0002 1
0003 D4/
0004 DATE
0005 10R

or in a 10-line dict:

0001 A
0002 1
0003 date
0004
0005
0006
0007 D4/
0008
0009 R
0010 10

If the date conversion is being done by an type expression instead of a conversion, or by a correlative on the 8th line of a 10-line dict instead of by a conversion on line 7, queries will likely not work. When you use a query like:
  SELECT INVOICE-FILE WITH DATE.DUE < "01/01/2012"
the query processor uses the conversion code to convert "01/01/2012" into internal format, and then compare against the internal data on file. If you don't have data in internal format, then this is just a string comparison, and "01/01/2012" is NOT equal to "01/01/12", and "02/01/2000" is great than "01/01/2012".


On Jan 24, 2012, at 8:17 AM, Barry Rogen wrote:

>
> We have been experiencing this quite a bit and am not sure why we are getting mis-comparisions.  Below is a simplified example of our issue
>
> B$CHECK.855.SENT:  51:          IF ST.DATE # "" THEN
> B$CHECK.855.SENT:  52:             IF ST.DATE < "12-31-11" THEN
> B$CHECK.855.SENT:  53:                PRINT PL:"Date is less than  12-31-11...":
>
> : ST.DATE/
> STRING: T r L=8 `01-20-12'
>
> We  have this issue with programs and with SELECT statements throughout. When you qualify a  date for this year to a date from 2011 it  screws up.
>
>
> Barry Rogen
> Senior Programmer/Analyst
> PNY Technologies, Inc.
> (973) 560-5327
> brogen@...<mailto:brogen@...>
>
> ------------------------------------------------------------------------------------------------------------------------
>        We are continually faced with great opportunities brilliantly disguised as insoluble problems.
>                                                             John W Gardner
> ------------------------------------------------------------------------------------------------------------------------
> [http://thinkbeforeprinting.org/struct/signature-1.gif]
>
>
>
>
>  ________________________________
> NOT INTENDED AS A SUBSTITUTE FOR A WRITING
> NOTHING IN THIS E-MAIL, IN ANY E-MAIL THREAD OF WHICH IT MAY BE A PART, OR IN ANY ATTACHMENTS THERETO, SHALL CONSTITUTE A BINDING CONTRACT, OR ANY CONTRACTUAL OBLIGATION BY PNY, OR ANY INTENT TO ENTER INTO ANY BINDING OBLIGATIONS, NOTWITHSTANDING ANY ENACTMENT OF THE UNIFORM ELECTRONIC TRANSACTIONS ACT, THE FEDERAL E-SIGN ACT, OR ANY OTHER STATE OR FEDERAL LAW OF SIMILAR SUBSTANCE OR EFFECT. THIS EMAIL MESSAGE, ITS CONTENTS AND ATTACHMENTS ARE NOT INTENDED TO REPRESENT AN OFFER OR ACCEPTANCE OF AN OFFER TO ENTER INTO A CONTRACT. NOTHING IN THIS E-MAIL, IN ANY E-MAIL THREAD OF WHICH IT MAY BE A PART, OR IN ANY ATTACHMENTS THERETO SHALL ALTER THIS DISCLAIMER.
>
> This e-mail message from PNY Technologies, Inc. is for the sole use of the intended recipient(s) and may contain confidential and privileged information. Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipient, please contact the sender by reply e-mail and destroy all copies of the original message.
> _______________________________________________
> U2-Users mailing list
> U2-Users@...
> http://listserver.u2ug.org/mailman/listinfo/u2-users

_______________________________________________
U2-Users mailing list
U2-Users@...
http://listserver.u2ug.org/mailman/listinfo/u2-users