# Thread: Formula opimization?

1. Registered User
Join Date
Nov 2004
Posts
6

## Unanswered: Formula opimization?

I would like to optimize the following code so how should I do it? Problem is that current data is on string format and I'd like to have it on number format:

Current data:
May 01, 2003 (string)
May 01, 2003 (string)
May 01, 2003 (string)
May 01, 2003 (string)
May 01, 2003 (string)
May 02, 2003 (string)
May 02, 2003 (string)
May 02, 2003 (string)
.
.
.
All above issues are separete formulas in the formula workshop:
1)[formula description = A - month]
Left ({REGDA},3 )

2) [formula description = A - day]
Mid ({REGDA},5 ,2 )

3) [formula description = A - year]
Right ({REGDA},4 )

4) [formula description = B - month value to number]
if {@A - month} = "Jan" then "01"
else if {@A - month} = "Feb" then "02"
else if {@A - month} = "Mar" then "03"
else if {@A - month} = "Apr" then "04"
else if {@A - month} = "May" then "05"
else if {@A - month} = "Jun" then "06"
else if {@A - month} = "Jul" then "07"
else if {@A - month} = "Aug" then "08"
else if {@A - month} = "Sep" then "09"
else if {@A - month} = "Oct" then "10"
else if {@A - month} = "Nov" then "11"
else if {@A - month} = "Dec" then "12"
else "--"

5) [formula description = C - month - string to number]
If NumericText ({@B - month to num}) Then
ToNumber ({@B - month to num})
Else 0

6) [formula description = day - string to number]
If NumericText ({@A - day to num}) Then
ToNumber ({@A - day to num})
Else 0

7) [formula description = year - string to number]
If NumericText ({@A - year}) Then
ToNumber ({@A - year})
Else 0

Final code:
8) DateTime ({@C - tonum-year},{@C - tonum-month} ,{@C - tonum-day} )

How this can be done easier (formula optimization)?

2. Registered User
Join Date
Jan 2004
Location
Jersey, UK
Posts
108
Sorry, although you gave a very detailed explanation I still don't understand what you'd like to achieve.

Do you want some code to do everything that is contained in your points 1-8?

Andy

3. Registered User
Join Date
Nov 2004
Posts
6
Originally Posted by randycarpet
Do you want some code to do everything that is contained in your points 1-8?
Yes, and I'd like to know that is there any other way to do the same formula? Is there unneccessary steps in my formula?

4. Registered User
Join Date
Dec 2004
Posts
3
plus keep in mind that the it is a string not a number field...

5. Registered User
Join Date
Jan 2004
Location
Jersey, UK
Posts
108

## Formula datetimevalue

Hi

Sorry for the late reply but I've been very busy recently. You can use the DateTimeValue formula to convert a string date to a date. Create a new formula field like so:

datetimevalue({your data here})

When you drag and show this field in your report you'll be able to format the date as you would any other date field.

Hope it works for you.

Regards - Andy

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•