Microsoft Word mergefield token polish currency formatting - word-2013

I want to Format number from 1,234.25 to 1 234,25. I tried below mergefield formatting but it did not gave the expected result {MergeField token \# "# ###,##"}. I have been googling whole day but no luck.

You could do some math to re-format your output.
For example, you want "token" formatted to: zł100,01 from 100.01
Try the following
zł{= INT({MERGEFIELD token})},{=INT({MERGEFIELD token}*100) - INT({MERGEFIELD token})*100)
Above, you can see how to calculate the integer portion and the fractional portions separately and manually placing a "," between them.
NOTE: {=} should be entered as a mail merge field similar to { MERGEFIELD }
Cheers,
Kevin

Related

Extract a substring using XPath where there might be no trailing delimiter in the field

I'm trying to parse an XML file where the users (in their infinite wisdom) type a key value into a free-form field, <Description>. The values are normally typed in with returns (BR's?) between them. For instance:
<Description>
% Increase: 27%
Completion Date: 10-Aug-2015
</Description>
I need to look for an extract the date following the string "Completion Date:" Looking around here on SO I found something similar and adapted it to:
compdate = deal.SelectSingleNode("./Terms/Description[substring-before(substring-after(.,'Completion Date:'),'/')]")
The problem is that in the original question there was a trailing character that could be used to delimit the text, a /. In my case, there might be a BR of some sort, or it might be the last (as in this case) or only item on the line and thus there's no delimiter.
So... suggestions on how to extract the date? I can do it on the VB side, but I'd like to remain in the XPath world for code clarity - unless of course the resulting XPath is unreadable.
If XPath 2.0 solution is acceptable, try
./Terms/Description/tokenize(substring-after(.,'Completion Date: '), '\n')[1]
If not and date format is always DD-mon-YYYY (e.g. 01-Dec-2018), try
./Terms/Description/substring(substring-after(.,'Completion Date: '), 1, 11)

Date in Excel from SQL

I have an excel created from a comma-delimited text file originally from a .sql file with an SQL INSERT query.
In one of the columns I have: "Cast(0x123456AB...) As TIME
Obviously this is NOT the jsondate format... so no help from that question...
I replaced the Cast( and replaced the ") As TIME" with empty strings.
So now I have the time values in hexadecimal.
How do I convert them into Excel Time or Datetime?
OK Playing around with it showed me that it's exactly the same as the jquery date answer. You take the numeric portion starting with 0x.
Take the 10 digits AFTER the 0x. e.g. in A2: =MID(A1, 3, 10)
Turn it into hexadecimal e.g. in A3: = HEX2DEC(A2)
Divide by 86400 e.g. A4: =A3/86400
And add the result to 1/1/1970 date. e.g. = A5: =A4 + Date(1970, 1, 1)
Or in short:
=(hex2dec(mid(a1,numstart,10))/86400) + date(1970,1,1)
Replace numstart with the 1-starting index of the number.
e.g. 3 if you have a 12 or 13 digit number like 0x12345678AB and you'll get 12345678AB
This is similar to the Convert JSON Date /Date(1388624400000)/ to Date in Excel
Except that:
a. The question was answered wrong and wouldn't work. (I edited it)
b. The .sql file was retrieved in a stored procedure from the database via SQL. While in the question they were using jquery returned ajax data, which seemed to differ. Turns out they're the same number with a different format.
As an added remark, I had a space mark at the beginning of my hex number. Until I did the MID on it, I didn't see that.
Note: When using ajax returned formatted dates like /date:0x12345678ab/ you'll set numstart to 8. If hex2dec fails, try turning the hex string into uppercase
before calling hex2dec. To debug just put each formula in a separate cell, so you see what works and what doesn't.

Set standard number format with thousand separator, 2 decimals and minus sign for negative numbers using VBA?

I've seen the question asked before on stackoverflow, how to get normal number format with thousand separator and 2 decimals. The answer was to set:
rng.NumberFormat = "##0.00"
But this is incomplete, because, at least on my computer, I don't get any space separator between millions and thousands. So I have changed that to:
rng.NumberFormat = "### ### ##0.00"
But this is again incomplete, because for some reason negative numbers were formatted to look like they have a space between the minus sign and the number. See below:
- 12.4
So, there are some things left to do to arrive at Excels "built-in" "format as number" formats. Additionally the formatting that I apply though VBA is described as Custom by Excel.
Is there any way to set the format to be the standard built in format as number with thousand separators, 2 decimals and minus signs for negative numbers?
I'm looking for something like:
rng.NumberFormat = "Number, 2, minus"
rng.NumberFormat = "# ##0.00:-# ##0.00"
You put the format for positive numbers before : and the format for negative after. You don't need to put hundreds of # signs in the format, just enough to show what the 1000's separator is.

Reformatting a Phone Number in Access

I'm in the process of uploading data into an access database, and some of the data has phone numbers listed in the format of 9999999999 and others are listed as 999-999-9999. I would like for all the numbers to read 9999999999 so that way they can be cross referenced. I've been trying to run an update query on the numbers that are in the undesired format, but I am having no success. Blow is how I have the query set up:
Field: Wireless Number
Table: Table to be updated
Update to: Mid([Table].[Wireless Number],2,3)+Mid([Table].[Wireless Number],7,3)+Right([Table].[Wireless Number],4)
Criteria: Not Like "**********"
Obviously, I'm not sure how to go about this, so that set up is a shot in the dark. What is the best way to go about getting the format that I need ?
This SQL function should work, replace [wireless num] with your field name:
test: IIf(Mid([wireless num],4,1)="-",Left([wireless num],3) & Mid([wireless num],5,3) & Right([wireless num],4),[Wireless Num])
If the 4th character is a -, that means it is undesired. In that scenario, it extracts each section of the phone number as substrings, concatenates them, and displays them as one string.
If the 4th character is not a -, we can assume the phone number is in the desired format.
This should also work:
Replace([wireless num],"-","")
It searches the Wireless Num field for -, and replaces it with a zero length string.

How can you format the result of a formula as s number

I'm using a formula in Excel 2007 to grab a mailbox size from a string. I'm stripping out all of the text before and after, and removing the , characters, yet Excel will not format the result as a number.
Because of this, I can't run any statistics such as total size or average size.
=SUBSTITUTE(MID(MailboxEX01[[#This Row],[TotalItemSize]], FIND("(", MailboxEX01[[#This Row],[TotalItemSize]]) + 1, FIND("bytes", MailboxEX01[[#This Row],[TotalItemSize]]) - (FIND("(", MailboxEX01[[#This Row],[TotalItemSize]]) + 2)), ",", "")
I tried =TEXT({the above}, "#,##0"), which successfully added the , character as the thousands separator, but (I guess unsurprisingly) still failed to format the cell as a number.
Does anybody know how I can force the result in this cell to format as a number? Thanks.
Your formula takes text values, strips stuff out, and replaces stuff. But the result is still text. If the result of that formula contains only the characters 0 to 9, you can coerce it into a number by using
={your formula}+0
or
={your formula}*1
or
=--({your formula})
Using =TEXT({your formula}, "format") will not produce a number. The TEXT() function returns text, as the name implies.
But if you use a mathematical operator on a number that is stored as text (or a text that represents a number), the maths operation will coerce that text value into a real number. The third suggestion uses the double unary (Google that) to coerce the text into a number.