Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

syntax help on dates

Status
Not open for further replies.

santango

Programmer
Jul 8, 2004
18
CA
hepls please

i need to comper two dates and have the clouser one
what will be the basic sintax for this.

thanks
sam
 
Do a formula field: If Date1 > Date2 then Date1 else Date2.

That's for 'most recent'. If you're compairing them to some other date, you'd need DateDiff.

[yinyang] Madawc Williams (East Anglia, UK) [yinyang]
 
IF {VENDOR.CURRENCY_ID} = "US ($)" THEN
DIM DATE_DIF
DATE_DIF = DateDiff ("d", {VENDOR_QUOTE.QUOTE_DATE}, {CURRENCY_EXCHANGE.EFFECTIVE_DATE})
if DATE_DIF < 0 then
formula = {VENDOR_QUOTE.DEFAULT_UNIT_PRICE}/{CURRENCY_EXCHANGE.SELL_RATE}
end if

there 10 firerent date on te table currency date i need de closer one to the quote date ????
while wil be perfect to do this bat i dont this is what i dont know (basic syntax)...
 
I've not tried using arrays in Crystal. Can anyone else help?

[yinyang] Madawc Williams (East Anglia, UK) [yinyang]
 
i cannot advance on this

well may be if onyone know who to select the first smoll date

Rem Basic syntax
Dim d1, d2, total,x
d1 = {VENDOR_QUOTE.QUOTE_DATE}
d2 = {CURRENCY_EXCHANGE.EFFECTIVE_DATE}
total = DateDiff ("d", d1, d2)
formula = total <= 1 'Here i need the first < only
 
I don't know basic syntax, but if you first used a record selection formula like:

{VENDOR_QUOTE.QUOTE_DATE} > {CURRENCY_EXCHANGE.EFFECTIVE_DATE}

...then you could create a formula for {@datediff}:

datediff("d",{VENDOR_QUOTE.QUOTE_DATE}{CURRENCY_EXCHANGE.EFFECTIVE_DATE})

These will all be negative numbers, so I think you could then get the closest date by using a formula:

maximum({@datediff})

-LB
 
IF {VENDOR.CURRENCY_ID} = "CAN ($)" THEN
FORMULA = {VENDOR_QUOTE.DEFAULT_UNIT_PRICE}
ELSE
IF {VENDOR.CURRENCY_ID} = "US ($)" THEN
dim x

x = datediff("d",{VENDOR_QUOTE.QUOTE_DATE},{CURRENCY_EXCHANGE.EFFECTIVE_DATE})

FORMULA = x
END IF
END IF

this formula givime this result

616.00 False 616.00 31-Oct-2002 1,550.00'i need this
862.00 False 862.00 4-Jul-2003 1,550.00
921.00 False 921.00 1-Sep-2003 1,665.83
952.00 False 952.00 2-Oct-2003 1,705.52
1,054.00 False 1,054.00 12-Jan-2004 1,771.02
1,106.00 False 1,106.00 4-Mar-2004 1,749.49
1,166.00 False 1,166.00 3-May-2004 1,731.91
1,256.00 False 1,256.00 1-Aug-2004 1,758.77
1,349.00 False 1,349.00 2-Nov-2004 1,864.56


thank
 
Why isn't the answer something like

Minimum({VENDOR_QUOTE.QUOTE_DATE}, {CURRENCY_EXCHANGE.EFFECTIVE_DATE}) ...?

Maybe I don't understand. That seems likely.

Scott.
 
i fild that i am close with this but i dont know where or who to use

Minimum({VENDOR_QUOTE.QUOTE_DATE}, {CURRENCY_EXCHANGE.EFFECTIVE_DATE})

if i do new formula erro massage

there must be a group that matches this field
 
Did you try my solution? I'm assuming that if the dates look like this:

Effective Date Quote Date
1-Mar-05 2-Jun-05
3-Apr-05 2-Jun-05
8-May-05-you want this one 2-Jun-05
15-Jun-05 2-Jun-05

...that you want the first effective date right before the quote date. Therefore, you don't want any effective dates that are greater than the quote date, and so you should use a record selection formula like:

{VENDOR_QUOTE.QUOTE_DATE} > {CURRENCY_EXCHANGE.EFFECTIVE_DATE}

Then when you use the datediff formula, as in:

Rem Basic syntax
Dim d1, d2, total,x
d1 = {VENDOR_QUOTE.QUOTE_DATE}
d2 = {CURRENCY_EXCHANGE.EFFECTIVE_DATE}
formula = DateDiff ("d", d1, d2)

...the result will always be negative. For the example, above, after using the record selection formula, the results would look like:

Effective Date Quote Date Datediff
1-Mar-05 2-Jun-05 -96
3-Apr-05 2-Jun-05 -63
8-May-05 2-Jun-05 -28

You need to insert a group on {VENDOR_QUOTE.QUOTE_DATE}. Then, to get the closest Effective Date, you would then need to right click on the Effective Date and insert a maximum to get 8-May-05.

If you only want to show that row in your report, then go to report->selection formula->GROUP and enter:

{CURRENCY_EXCHANGE.EFFECTIVE_DATE} = maximum({CURRENCY_EXCHANGE.EFFECTIVE_DATE},{VENDOR_QUOTE.QUOTE_DATE})

-LB
 
ok finaly works

thanks to all of you

this last formula works very good
 
Sorry I couldn't get back to you earlier. I gave you the formula in the wrong form for this.

I'm glad you got it working. Mine should have read more like this:


Minimum({VENDOR_QUOTE.QUOTE_DATE} to {CURRENCY_EXCHANGE.EFFECTIVE_DATE})


Apologies for steering you astray with that comma.

I'm away from crystal at the moment so I can't test it. As long as you got something working though you won't need it.

Scott.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top