Format Cell Phone number on Crystal Reports - crystal-reports

I searched for a formula to format 10 digit cell phone number on Crystal reports.The output should be this type-(856)854-8098.The formula was:
Picture(ToText({Command.Cell Phone},"##########"),"(xxx) xxx-xxxx")
When I applied it on my report it gave an error on the highlighted part saying "Too many arguments have been given to this function"
Please suggest,how should I modify it to work properly.

I copied your original formula to my report and substituted your command field with a formula containing the phone number you provided. I was able to add it to the report just fine. One debugging option is to hardcode the phone number into a formula on your end and then substitute {Command.CellPhone} with the formula and retest.
I was also able to get it to work by placing this in a formula:
Picture(ToText({#phonenum},"0",0),"(xxx) xxx-xxxx")
Lastly, a dirtier alternative is to place the following in a formula:
'(' & mid(totext({#phonenumber},"0",0),1,3) & ')' & ' ' & Mid(totext({#phonenumber},"0",0),4,3) & '-' & Mid(totext({#phonenumber},"0",0),7,4)
Note:
This solution assumes that the cellphone number field will always be 10 digits
Replace {#phonenumber} with your phone number field from the report Command.

Related

Crystal Report how to remove a line with "string"

Is it possible to just display second line of "SST" only using crystal report to extract the value from that field.
My coding is below:
using Mid
mid({Invoice.InvGSTSumCode},4)
using Carriage return
Trim(split({Invoice.InvGSTSumCode},chr(13))[2])
Result come out is not what i want, it give me an extra one line space
There's probably also a line feed character -- Chr(10) -- hiding in there.
So use something like: split({Invoice.InvGSTSumCode},chr(10) + chr(13))[2]

Google Sheets - Concatenate NOW-1, slash, and NOW+120

In Google Sheets, I need to create a date in the following format:
2016-06-15T12:00-0800/2016-10-16T12:00-0800
(Yesterday's date / today's date + 120 days)
Using =NOW()-1, I get yesterday's date.
Using Format - Date - More - Year(1930)-Month(05)-Day(01)T:Hour(01):00-0800, I get the proper format for the 1st part of the date range (2016-06-15T12:00-0800).
Repeating the same process with =NOW()+120.
Got the 2nd part of the date range (2016-10-16T12:00-0800).
PROBLEM: Trying to =CONCATENATE(A2,"/",B2), results in this:
42901.6965777315/43022.6965777315
...and no matter what I do - change the format, try to use =CONCATENATE(=TEXT(A2),"/",=TEXT(B2)), or other tricks I know, I either get a blank cell, an error message, or an even worse mess.
All I want is to combine 2 date cells into 1, with a slash in between. How can this be accomplished?
Try join instead of concatenate:
=join("/",A1,B1)
Maybe:
=text(now()-1,"yyyy-mm-ddThh:mm")&"-0800/"&text(now()+120,"yyyy-mm-ddThh:mm")&"-0800"
TEXT with only a date as argument returns the serial number corresponding to that date,
First you should confer the result of you formulas that involves NOW to a formatted text by using TEXT with the second argument. Then you could concatenate the result of that.
The above be donde on a single formula but you maybe should start by doing each step on separate cells in order to make it easy to check the result of each part.

Raw Excel Data contains different Date formats

I have huge amounts of raw data that are separated by columns. All is well when i import these to Matlab except for the fact that I just saw that the excel files contains different formats for the dates.
One series (i.e 3 days, 1 row or each hour gets 3x24 rows) have its' dates in the format "mm/dd/yyyy" which neither excel or matlab recognizes as proper dates.
I've tried solving this problem in different ways. First i tried to just highlight the cells and use the function format cells, but this didn't work since excel doesn't see them as 'cells' but rather as 'text'.
Then i tried the Text to columns function which didn't work either (delimited or fixed width).
Im really stuck and would appreciate some help with this.
In Excel:
If cell A1 has a string like mm/dd/yyyy then try this:
=DATE(RIGHT(A1,4), LEFT(A1,2), MID(A1,4,2))
In Matlab:
=datenum(yourDateString, 'mm/dd/yyyy')
Select the desired range to fix and use this script:
Sub bulk_Date_fix()
on error resume next
Set d_ranged = Selection
For Each a In d_ranged
a.Value = Split(a.Value, "/")(0) & "/" & Split(a.Value, "/")(1) & "/" & Split(a.Value, "/")(2)
Next
on error goto 0
End Sub
How it works: The above script loops through all the cells in the selected area and splits out the various attributes of a date based on the "/" symbol.
I examined your file and you will need to go back to the source data to straighten this out. Instead of "opening" the file in Excel, you will need to IMPORT the file. When you do that, the text import wizard will open, and you can then designate the date column as being of the format DMY (or whatever format is being generated by the source).
The problem is that there is a mismatch between the format of the file, and your Windows Regional Short date format. If you look at Row 229, you will see that real dates are present, but out of sequence with the rest.
Excel parses dates being input according to the Windows Regional Short Date settings. If the date doesn't make sense, according to that parsing (e.g. month > 12) , Excel will interpret the date as a string; if the date does make sense, it will be interpreted as a date in accordance with that windows regional date component order, and this will be different from what is intended.
So the first few hundred dates are strings, but at line 229, the date, which is probably meant to be 12 OCT 2014, gets changed to 10 DEC 2014. This will happen in other areas where that value in the 2nd position is 12 or less.
EDIT: I am not certain of the variabilities inherent in using XL on the MAC. In the Windows version of XL, the "text import" feature is on the Data Ribbon / Get External Data Tab:
When you click on that and open a text file, you will see the Text Import Wizard, and when you get to Step 3, you will be able to specify the text format of the data to be imported:

Data field formatting

I am trying to format a number field to display in this particular way 0001234,
i can do it in VB using the Format(right command, but crystal basic doesn't recognise 'Format'
This Crystal formula will add 0s to the left of the number until it is 7 digits long. The cstr() is there to get rid of the decimal and the characters to the right of the decimal:
Right("0000000"&
cstr({Field},0,"")
,7)
I recommend putting this formula in the display string of your field.

Formatting a field using ToText in a Crystal Reports formula field

I'm trying to create a Crystal Reports formula field (to calculate the percentage change in a price) that will return "N/A" if a particular report field is null, but return a number to two decimal places using accounting format (negative numbers surrounded by parentheses) if it is not.
The closest I have been able to manage is this:
If IsNull({ValuationReport.YestPrice}) Then
'N/A'
Else
ToText({#Price}/{ValuationReport.YestPrice}*100-100, '###.00', 2)
However this represents negative numbers using a negative sign, not parentheses.
I tried format strings like '###.00;(###.00)' and '(###.00)' but these were rejected as invalid. How can I achieve my goal?
I think you are looking for ToText(CCur(#Price}/{ValuationReport.YestPrice}*100-100))
You can use CCur to convert numbers or string to Curency formats. CCur(number) or CCur(string)
I think this may be what you are looking for,
Replace (ToText(CCur({field})),"$" , "") that will give the parentheses for negative numbers
It is a little hacky, but I'm not sure CR is very kind in the ways of formatting
if(isnull({uspRptMonthlyGasRevenueByGas;1.YearTotal})) = true then
"nd"
else
totext({uspRptMonthlyGasRevenueByGas;1.YearTotal},'###.00')
The above logic should be what you are looking for.