Here I'm using the following formula in my crystal report to find the aging of a product. I have taken my manufacturing Date as Default_Date and Date to compare as current date.
datediff("d",CDate({Yarn_Packing_Weighment_Entry.Default_Date}),CurrentDate)
The formula have no errors but when date is from 1st to 12th - The difference results are wrong
and after 13th to 31st -
DOP Column date is which I'm comparing with Currentdate. A screenshot is attached
Please advice me where I'm wrong. Thanks in advance
I assume your database field {Yarn_Packing_Weighment_Entry.Default_Date} is in DD/MM/YYYY format. CDATE does not work well with these dates. It tries to but it doesn't work very well. I am sure there are many different creative ways to handle this but here is my offer
datediff("d",
cdate(
split({Yarn_Packing_Weighment_Entry.Default_Date},"/")[2]
+"/"+
split({Yarn_Packing_Weighment_Entry.Default_Date},"/")[1]
+"/"+
split({Yarn_Packing_Weighment_Entry.Default_Date},"/")[3]
),
currentdate
)