How to compair two date fields

vyanku
Member Posts: 791
I want to compair two dates like
But If one of the date is zero then only the loop is going to be executed correctly .If both date fields contains date then only first part of loop will execute in any condition.
Why this happend??
How can I compair two date fields??
IF "Purch. Rcpt. Line"."Promised Receipt Date" <= "Purch. Rcpt. Line"."Receipt Date" THEN BEGIN qty := "Purch. Rcpt. Line"."Total recived"; END ELSE BEGIN qty1 := "Purch. Rcpt. Line"."Total recived"; END;
But If one of the date is zero then only the loop is going to be executed correctly .If both date fields contains date then only first part of loop will execute in any condition.
Why this happend??
How can I compair two date fields??
0
Answers
-
IF "Purch. Rcpt. Line"."Promised Receipt Date" <= "Purch. Rcpt. Line"."Receipt Date" THEN
BEGIN
qty := "Purch. Rcpt. Line"."Total recived";
END
ELSE
BEGIN
qty1 := "Purch. Rcpt. Line"."Total recived";
END;
Seems correct to me also...do check the dates in the table.Diptish Naskar
For any queries you can also visit my blog site: http://msnavarena.blogspot.com/0 -
vyanku wrote:I want to compair two dates like
IF "Purch. Rcpt. Line"."Promised Receipt Date" <= "Purch. Rcpt. Line"."Receipt Date" THEN BEGIN qty := "Purch. Rcpt. Line"."Total recived"; END ELSE BEGIN qty1 := "Purch. Rcpt. Line"."Total recived"; END;
But If one of the date is zero then only the loop is going to be executed correctly .If both date fields contains date then only first part of loop will execute in any condition.
Why this happend??
How can I compair two date fields??0 -
Perhaps this may be a solution:
IF ("Purch. Rcpt. Line"."Promised Receipt Date" <> 0D) AND ("Purch. Rcpt. Line"."Promised Receipt Date" <= "Purch. Rcpt. Line"."Receipt Date") THEN BEGIN qty := "Purch. Rcpt. Line"."Total recived"; END ELSE BEGIN qty1 := "Purch. Rcpt. Line"."Total recived"; END;
if not, you have to explain more detailed, what you want the code to do.How can I compair two date fields??br
Josef Metz0 -
This is the code I used, which probably looks a lot like everything else posted:IF ("sales shipment header"."Shipment Date" <> 0D) AND
("Planned Shipment Date" <> 0D) THEN BEGIN
OnTime := "sales shipment header"."Shipment Date" - "Planned Shipment Date";0 -
I just want to compair two dates likeIF 01-01-07<= 10-01-07 THEN
BEGIN
qty := "Purch. Rcpt. Line"."Total recived";
END
ELSE
BEGIN
qty1 := "Purch. Rcpt. Line"."Total recived";
END;
here if the value of first date is zero then only it execute the else part
If it is not zero then it executes only if part even it the date is 15-01-07.
This is my main problem.
I wanted to create report for vendor performance.In that report there are two columns .If the quantity is recived within the time i.e.within promice date and posting date the the quantity should be appeare in first column else it should be appear in another column.0 -
vyanku,
Your code is correct. The problem seem to be elsewhere.
In wich trigger of the report did you put the code ?0 -
"Purch. Rcpt. Line" OnAfterGetRecord()0
-
anybody please suggest [-o<0
-
Something like this:
IF ("Purch. Rcpt. Line"."Promised Receipt Date" = 0D) OR ("Purch. Rcpt. Line"."Receipt Date" =0D) THEN BEGIN //Do what you need to do if one of the dates is zero END ELSE BEGIN IF "Purch. Rcpt. Line"."Promised Receipt Date" <= "Purch. Rcpt. Line"."Receipt Date" THEN BEGIN qty := "Purch. Rcpt. Line"."Total recived"; END ELSE BEGIN qty1 := "Purch. Rcpt. Line"."Total recived"; END; END;
Is that what you mean?0 -
No.
Can we compair dates like this
if 01-01-07 < 02-01-07 then
.....??
or
if first date is older i.e. smaller than second date then ...
Is it possible in navision??? How??
If my code is correct then why it executes only if part of the loop?? why not else loop even when I insert date smaller or greater than the recipt date???0 -
The computer is very dumb, it can only do exactly what you tell it to do. It executes the TRUE part of your IF statement because your expression evaluates to TRUE. That is all there is to it.
Let me say that again: Your expression evaluates to TRUE, and therefore the TRUE part of your IF statement is executed.
If it doesn't do what you want it to do, then you rewrite the expresion in such a way that it evaluates to TRUE on your conditions, there's nothing else I can say about that.
If you don't understand the difference between true and false, or how to write a line of code to evaluate a condition, then it is probably time you found another line of work.0 -
vyanku wrote:Can we compair dates like this
if 01-01-07 < 02-01-07 then
.....??
or
if first date is older i.e. smaller than second date then ...
Is it possible in navision??? How??
You need to think about your code and rewrite it so that it does what you want it to do. Right now you're just asking the same question over and over.0 -
Thanks.
My problem is solved.
Thanku very much.0 -
I am also facing the same problem please help me.Thanks&Regards
Himanshu Yadav
(Dynamics NAV)0 -
i think the most polite answer i can offer - RTFM. Google for RTFM if you don't know what is it.0
-
Your code is correct. The problem seem to be elsewhere.
In wich trigger of the report did you put the code ?
________________
daily deals, online shopping sites, hot deals, best deals0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions