Link to home
Start Free TrialLog in
Avatar of rbnaz
rbnazFlag for United States of America

asked on

Formula to format date from using "/" to "-".

In Crystal Reports, I need a formula  to change CurrentDate from mm/dd/yyyy to mm-dd-yy without changing Options/Fields/Date.
Avatar of Norie
Norie

Perhaps.

totext(CurrentDate, "mm-dd-yy")
Avatar of rbnaz

ASKER

That gives me "mm-dd-yy" in text format.
What are you trying to do?

YOu should be able to simply set a custom format for the field

Right click the field on the report
Click FORMAT FIELD
Click the DATE tab
Select the format if it is shown or click CUSTOMIZE
Set the format as desired

mlmcc
Avatar of rbnaz

ASKER

I am putting the field into a formula which is used to create a barcode. The following works: Replace(totext(currentdate), "/", "-"), though it uses "yyyy" instead of "yy".
Don't you have to specify a format, e.g. mm/dd/yyyy, when using totext?

ToText({table.datefield},"MM/dd/yyyy")

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Mike McCracken
Mike McCracken

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of rbnaz

ASKER

Making the year from four digits to two digits makes the barcode smaller. Thanks.