Date Prompt Format

Hi BOB users

I am looking to change the format in a static date prompt on a report from YYYY MM DD to DD MM YYYY, is this possible? I have attempted a number of methods after reading the article below but I am unsure of exactly what I am doing.

Many thanks


juno (BOB member since 2008-06-23)

Do you mean the format of the date AFTER you`ve picked it from the calendar picker?


ABILtd :uk: (BOB member since 2006-02-08)

Hi Andy, To either have the option to free type or select from the calendar. At the moment the prompts are set up to take either in the format YYYY-MM-DD.

thanks


juno (BOB member since 2008-06-23)

A parameter will prompt in a different way depending on the datatype. If you set it as a date parameter it will give you the calendar, set to text\char it will give you free text.

Which one are you using and what is the data type of the column in the DB that you`ll be using the parameter with for filtering?


ABILtd :uk: (BOB member since 2006-02-08)

Set as a Date datatype Andy, is there any way you can cast/convert it in the report to change the format without loosing the calendar?


juno (BOB member since 2008-06-23)

Yeah, course you can.

You can use the parameter field in a formula and convert it to a string and do anything with it basically. You can then use this variable\formula in record selection or whereever you need to. Performance won`t be good though as all data will have to be parsed through that formula if you use it in a record selection formula.


ABILtd :uk: (BOB member since 2006-02-08)

Forgive my ignorance but do I simply create a new formula, do the converson(Any code snippets? :lol: ), then reference this field in my new parameter?


juno (BOB member since 2008-06-23)

Thats exactly the workflow.

Don`t have any examples though. My 2008 install is currently dead.


ABILtd :uk: (BOB member since 2006-02-08)

No worries, hope you get it fixed.


juno (BOB member since 2008-06-23)

Just as a follow on question to this topic does Crystal not support data type date in the DD-MM-YYYY format?


juno (BOB member since 2008-06-23)

It depends what you mean by support. Dates in databases generally aren`t stored in a specific format, they are just presented differently.

So it really depends on what your doing…

i.e. Crystal will display a date field in the format set in your regional settings unless you override it and force a format.


ABILtd :uk: (BOB member since 2006-02-08)

So it basically boils down to how the date is stored in the database(SQL server)? And am I right in saying that there are no conversion date functions within Cyrstal XI? In a business objects universe I would be able to convert the date format using the SQL server function convert.


juno (BOB member since 2008-06-23)

You can use that function in Crystal Reports if you use an SQL Expression field…:slight_smile:

Or connect the report to the same Universe!

All convert will do is turn the Datetime value to a date string formatted how you want it. You can still do that in the Crystal report formula language.

Best way is using an SQL Expression field though, better performance.


ABILtd :uk: (BOB member since 2006-02-08)

Apologies for my naivety but still struggling with this, I looked at using convert function in a SQL expression but the function available only seems to allow for 2 paramenters rather 3 in SQL Sever/Oracle.

Andy you mentioned that you can use Crystal report formula language to format a date, are you able to do this but still keep the data type as a date so I can still use it as a prompt with the calendar?

I have the following code in the selection formula and wish to have the date coming back as DD-MM-YYYY rather than YYYY-MM-DD

{DATE}>={?Start Date} and
{DATE}<={?End Date} and
{State} = “Closed”


juno (BOB member since 2008-06-23)