Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Date convertion to text then to number Post Reply Post New Topic
Author Message
shiloh
Newbie
Newbie


Joined: 13 Oct 2011
Online Status: Offline
Posts: 26
Quote shiloh Replybullet Topic: Date convertion to text then to number
     Posted: 13 Oct 2011 at 8:22pm
Hi everyone,

I'm new in crystal report, I using crystal report XI. I want to calculate my stock balance b/f, so I created this formula:

if ToText({Inventory.TxDate},"yyyy/MM/dd")<({?PMStart})//PMstart is string of yyyymm
   Then "A"
else
    "B"

This formula is work but the balance b/f is wrong.
My balance b/f is cut off the mmyyyy key in.

Can anyone please advice house do i solve this issue.
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 14 Oct 2011 at 5:31am
why not use:
 
if ToText({Inventory.TxDate},"yyyyMM")<({?PMStart})//PMstart is string of yyyymm
Then "A"
else
"B"
 
a longer string will never be less than a shorter string
 
20110101 > 201101
 
HTH
IP IP Logged
shiloh
Newbie
Newbie


Joined: 13 Oct 2011
Online Status: Offline
Posts: 26
Quote shiloh Replybullet Posted: 16 Oct 2011 at 10:11pm
Originally posted by lockwelle



why not use:
 
if ToText({Inventory.TxDate},"yyyyMM")<({?PMStart})//PMstart is string of yyyymm   Then "A" else    "B"
 
a longer string will never be less than a shorter string
 
20110101 > 201101
 
HTH


I have try that too, but my balance brought forward not appear...which ever I put also no b/f. Not sure which part go wrong.

Can other suggestion?

Thanks for help
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 17 Oct 2011 at 11:57am
last suggestion, standard debugging of formulas...
put ToText({Inventory.TxDate},"yyyyMM") in a formula, put {?PMStart} in another put  ToText({Inventory.TxDate},"yyyyMM") < {?PMStart} in a third.  Place them all on the report in the same section and observe the results. 
 
Many times, what I thought the result would be was not the value displayed.  Once you know what is being displayed, it is easier to correct.
 
HTH
IP IP Logged
shiloh
Newbie
Newbie


Joined: 13 Oct 2011
Online Status: Offline
Posts: 26
Quote shiloh Replybullet Posted: 17 Oct 2011 at 11:31pm
Originally posted by lockwelle



last suggestion, standard debugging of formulas...
put ToText({Inventory.TxDate},"yyyyMM") in a formula, put {?PMStart} in another put  ToText({Inventory.TxDate},"yyyyMM") < {?PMStart} in a third.  Place them all on the report in the same section and observe the results. 
 
Many times, what I thought the result would be was not the value displayed.  Once you know what is being displayed, it is easier to correct.
 
HTH


Thanks, I solve my problems already. This formula is worked. Is the other record selection setting which give me wrong result.

Thanks for help :)
IP IP Logged
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum