ABL: Retrieve MAX date

Good to know!

On Fri, Jan 13, 2012 at 11:49 AM, Joe Rojas <jrojas@...> wrote:

> **
>
>
> Thanks John.
> I tried this out but there is a gothca that I thought I would share.
>
> FOR FIRST effectively ignores the BY clause.
> The ABL reference guide says "The AVM finds the first record before any
> sorting."
>
> To get around this, you have to use FOR EACH and then use a LEAVE
> statement right after you retrieve the values you need from the first
> record.
>
> For example:
> FOR EACH CurrExRate WHERE CurrExRate.Company = CUR-COMP AND
> CurrExRate.RateGrpCode = "CONV"
> AND CurrExRate.EffectiveDate <= Today BY CurrExRate.EffectiveDate
> DESCENDING:
> ASSIGN dExchRate = CurrExRate.CurrentRate.
> LEAVE.
> END.
>
>
> -----Original Message-----
> From: vantage@yahoogroups.com [mailto:vantage@yahoogroups.com] On Behalf
> Of John Driggers
> Sent: Wednesday, January 11, 2012 4:28 PM
> To: vantage@yahoogroups.com
> Subject: Re: [Vantage] ABL: Retrieve MAX date
>
> FOR FIRST Table BY DateField DESCENDING.
>
> That should do it. Also, if it's a log or something where the highest
> entry is always the most recent record you can just use:
>
> FIND LAST Table.
>
> They both do the same thing, but the second example should be faster.
>
> On Wed, Jan 11, 2012 at 2:44 PM, Joe Rojas <jrojas@...> wrote:
>
> > **
>
> >
> >
> > Hi All,
> >
> > I'm working in the product configurator and I need to determine the
> > largest date in a specific field of a table and assign it to a
> variable.
> >
> > In TSQL, I could do it with something like
> >
> > SELECT @MaxDate = MAX(datefield) FROM tablename WHERE field = value
> >
> > How do I do this in ABL?
> >
> > [Non-text portions of this message have been removed]
> >
> >
> >
>
> --
> *John Driggers*
> *High End Dev, System Design, Profit Drinking
> *
> *:: 904.962.2887*
> *:: waffqle@...*
> *:: NO FAXES*
>
> *
>
>
> *
>
> [Non-text portions of this message have been removed]
>
> ------------------------------------
>
>
> Useful links for the Yahoo!Groups Vantage Board are: ( Note: You must
> have already linked your email address to a yahoo id to enable access. )
> (1) To access the Files Section of our Yahoo!Group for Report Builder
> and Crystal Reports and other 'goodies', please goto:
> http://groups.yahoo.com/group/vantage/files/.
> (2) To search through old msg's goto:
> http://groups.yahoo.com/group/vantage/messages
> (3) To view links to Vendors that provide Vantage services goto:
> http://groups.yahoo.com/group/vantage/linksYahoo! Groups Links
>
>
>



--
*John Driggers*
*High End Dev, System Design, Profit Drinking
*
*:: 904.962.2887*
*:: waffqle@...*
*:: NO FAXES*

*

*


[Non-text portions of this message have been removed]
Hi All,



I'm working in the product configurator and I need to determine the
largest date in a specific field of a table and assign it to a variable.



In TSQL, I could do it with something like

SELECT @MaxDate = MAX(datefield) FROM tablename WHERE field = value



How do I do this in ABL?



[Non-text portions of this message have been removed]
FOR FIRST Table BY DateField DESCENDING.

That should do it. Also, if it's a log or something where the highest entry
is always the most recent record you can just use:

FIND LAST Table.

They both do the same thing, but the second example should be faster.


On Wed, Jan 11, 2012 at 2:44 PM, Joe Rojas <jrojas@...> wrote:

> **
>
>
> Hi All,
>
> I'm working in the product configurator and I need to determine the
> largest date in a specific field of a table and assign it to a variable.
>
> In TSQL, I could do it with something like
>
> SELECT @MaxDate = MAX(datefield) FROM tablename WHERE field = value
>
> How do I do this in ABL?
>
> [Non-text portions of this message have been removed]
>
>
>



--
*John Driggers*
*High End Dev, System Design, Profit Drinking
*
*:: 904.962.2887*
*:: waffqle@...*
*:: NO FAXES*

*

*


[Non-text portions of this message have been removed]
Thanks John.
I tried this out but there is a gothca that I thought I would share.

FOR FIRST effectively ignores the BY clause.
The ABL reference guide says "The AVM finds the first record before any
sorting."

To get around this, you have to use FOR EACH and then use a LEAVE
statement right after you retrieve the values you need from the first
record.

For example:
FOR EACH CurrExRate WHERE CurrExRate.Company = CUR-COMP AND
CurrExRate.RateGrpCode = "CONV"
AND CurrExRate.EffectiveDate <= Today BY CurrExRate.EffectiveDate
DESCENDING:
ASSIGN dExchRate = CurrExRate.CurrentRate.
LEAVE.
END.


-----Original Message-----
From: vantage@yahoogroups.com [mailto:vantage@yahoogroups.com] On Behalf
Of John Driggers
Sent: Wednesday, January 11, 2012 4:28 PM
To: vantage@yahoogroups.com
Subject: Re: [Vantage] ABL: Retrieve MAX date

FOR FIRST Table BY DateField DESCENDING.

That should do it. Also, if it's a log or something where the highest
entry is always the most recent record you can just use:

FIND LAST Table.

They both do the same thing, but the second example should be faster.


On Wed, Jan 11, 2012 at 2:44 PM, Joe Rojas <jrojas@...> wrote:

> **
>
>
> Hi All,
>
> I'm working in the product configurator and I need to determine the
> largest date in a specific field of a table and assign it to a
variable.
>
> In TSQL, I could do it with something like
>
> SELECT @MaxDate = MAX(datefield) FROM tablename WHERE field = value
>
> How do I do this in ABL?
>
> [Non-text portions of this message have been removed]
>
>
>



--
*John Driggers*
*High End Dev, System Design, Profit Drinking
*
*:: 904.962.2887*
*:: waffqle@...*
*:: NO FAXES*

*

*


[Non-text portions of this message have been removed]



------------------------------------

Useful links for the Yahoo!Groups Vantage Board are: ( Note: You must
have already linked your email address to a yahoo id to enable access. )
(1) To access the Files Section of our Yahoo!Group for Report Builder
and Crystal Reports and other 'goodies', please goto:
http://groups.yahoo.com/group/vantage/files/.
(2) To search through old msg's goto:
http://groups.yahoo.com/group/vantage/messages
(3) To view links to Vendors that provide Vantage services goto:
http://groups.yahoo.com/group/vantage/linksYahoo! Groups Links