date compare in navision

I need to compare date in navision.

IF (“Sales Price”.“Ending Date”=TODAY) THEN BEGIN

end.

but it is not working.

help me

In what sense do you mean it is not working? What date does “Sales Price”.“Ending Date” contain? I this is not equal to TODAY (which is the system date of the computer running this code), the IF-statement will evaluate to FALSE.

It is working for me…

Write a simple Message(‘hi’); and test…

i have a current date value 06.03.12 for this ending date. but it is not working.

Where did you write the above code?

You have to Debug what value you have in this statement…

i undertand this is the date format problem.

today date format here is 06.03.12 . i meant dd-mm-yy

and database endingdate field value is 03.06.12.

how to change format here?

Dates are based on the Regional Settings in your System…

I know that but i have to change dd.mm.yy to mm.dd.yy. how to do this?

The formatting of dates if of no meaning in code. Then it uses an internal format which is not influenced by regional settings.

In Navision the 2 dates you are using have the same format (regional settings)…, so if Today is 06.03.12 it means DAY(6)-Month(3)-Year(2012). and if the endingdate is 03.06.12 it means Day(3)-Month(6)-Year(2012). So, that if statmente needs to return FALSE.

where did write that code? place a break point on that code and debug and check the value of enddate. Then only you can understant why it is skhipping. I hope system Date format is not the problem