Crystal Report formula meaning

Hi I have formula in crystal Report .

stringVar strTemp :=  "From Date: " 
+ FormatDate ({@DateFormat}, DTSToDate({@FromDate}))
+ NewLine () + "To Date: " + FormatDate ({@DateFormat}, DTSToDate({@ToDate}));

if {@UserId} <> "" then
  strTemp := strTemp + NewLine() + "User ID: " + {@UserId};

strTemp

can any one please tell me meaning of this?

I want to convert this into ssrs report.

Thanks.
riks89Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ecarboneCommented:
Hi riks,
We can go through it piece by piece:

- - - - -
stringVar strTemp :=  "From Date: "
+ FormatDate ({@DateFormat}, DTSToDate({@FromDate}))
+ NewLine () + "To Date: " + FormatDate ({@DateFormat}, DTSToDate({@ToDate}));
- - - - -


A variable called 'strTemp' is created. It has a data type of 'string'
It will hold the following string:

From Date: 08/16/2013
To Date: 10/01/2013


(The dates are just an example)

"DTSToDate({@FromDate})" is a function called 'Date Time String To Date'. It takes a string of text and tries to convert it into an actual date. The string of text must be in a proper format otherwise the function will fail. It returns only the Date (not the time). So for example if you feed "2013/08/16 10:15:27" into this function, it returns "2013/08/16"

It is placed inside of another function called "FormatDate", which formats the date according to your specified parameter.

"NewLine()" I suppose gives you a new line (lfcr) although I have never seen it. (What version of Crystal Reports are you using?)

OK, so far your variable contains the following:

From Date: 08/16/2013
To Date: 10/01/2013


The next block of code checks to see if "UserId" is not empty. (UserId is a custom formula in your report).

If UserId is NOT empty, it will add a new line, and then "User ID: John Smith" to the variable.

So... if UserId contains a value, your variable will now look like this:

From Date: 08/16/2013
To Date: 10/01/2013
User ID: John Smith


On the other hand, if UserId does NOT contain a value, this 'if' block of code is skipped, and therefore your variable will still look like this:

From Date: 08/16/2013
To Date: 10/01/2013


The final line of code:

- - - - -
strTemp
- - - - -


...This returns whatever is stored in the variable "strTemp"
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
James0628Commented:
ecarbone has given you a very detailed answer.  I'll just add that, like FormatDateTime in your other question, FormatDate is not a valid function in CR 10.  It may be a function in the version that you have.  Otherwise, it's a custom function on your system.

 James
0
riks89Author Commented:
Hi ecarbone ,

Thanks for make me understand logic of code. :)

I am using versoin 9.2

Again thank you so much.. :)

@James : Regarding FormatDate yeah It might be custome function in it. Actually I am  beginner in crystal reporting.

Thanks
0
planoczCommented:
Use in the textbox that the want the answer in.

="IIF (UserId = "", "", "From Date: " & Fomat(FromDate, "MM/dd/yyyy") & " To Date: " &  Fomat(ToDate, "MM/dd/yyyy") )
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Crystal Reports

From novice to tech pro — start learning today.