Writing millions of millions as letters - type-conversion

I have to write a function in Scheme (but any language would help, I just don't get the process) which writes any number, even a really big one as letters.
For example: "1000" outputs "one thousand". I'm stuck at converting numbers which are higher than 100 000 000 000. I can't write them as billions or trillions, they have to be "millions of millions". For example: '2 000 020 001 020' is 'two million twenty million one thousand twenty' and '3 000 000 000 000 000 005' is 'three million of million of million five'. How can I do that?

Related

Convert full words date into numbers

I have a bunch of dates in a database written in full worded text and I need to convert them into a useable date field. It's a one time deal but there's a few million lines so doing it manually is unthinkable.
"January the twenty sixth, nineteen eighty nine" would become "1989/01/26"
The format isn't always he same, I could also have "The nineteenth of August, nineteen hundred ninety"
Ideally doing it in SQL would be easier, but I could run a script and update the database after.
Any suggestions?
My code is too specific for my case to post here, but here's a pseudo-code of what I did for the numbers so maybe someone will be saved the headache, especially with numbers in French.
NumberString = 'Nineteen hundred ninety nine'
-- Replace each word individually by their value : Nineteen hundred ninety nine would be 19,100,90,9 (or 10,9,100,4,20,10,9 in French)
NumberString= '19 100 90 9'
-- For French only, replace '4 20' by 80 (easier for the next step)
Total = 0
NumberArray = NumberString.SplitOnSpaces
FOREACH Numbers as Number
IF Number is not a power of 100 THEN Total += Number
IF Number is a power of 100 THEN
IF Total%Number = 0 THEN Total += Number
ELSE
ModuloTemp = Total%Number
Total -= ModuloTemp
Total += ModuloTemp * Number
END
It won't work when the number is written in parts, like 2020 would be 'twenty twenty', but it was good enough for my needs.
Then for the date I just find the month's position. If it's day, month, year you can build back the date using the month as a separator. If it's month, day, year then you have to find the ordinal number (first, second, tenth, etc.) to distinguish the year from the day.

How to combine the date in different columns? (Tableau)

I have a dataset ab the donor of the organization. Each row starts with donor's ID and name, home address, donate_date_1, donate_amount_1, donate_date_2, donate_amount_2, keep going until 98. It looks similar to this
Donor_ID NAME donate_date_1 donate_amount_1 donate_date_2 donate_amount_2 Total_Amount
0 A Month/Day/Year 100 Month/Day/Year 200 300
1 B Month/Day/Year 200 Month/Day/Year 50 250
2 C Month/Day/Year 1000 Month/Day/Year 500 1500
The dataset has the donors' records from 1982. Every donor starts to donate on different date, ex: 2007 to donor1 is the first donation, but to donor 2 might be the 10th donation.
So here is my question: How can I combine all the dates to see which year the donors donate the most money and create the filter to see how much money was donated in total in the specific period?

Postgresql max TransactionId > 4 billion

The max transactionId of Postgresql should be 2^31 which is 2 billion, however, when I query the current transactionId from DB via select cast(txid_current() as text) I got the number 8 billion. why does this happen? The autovacuum_freeze_max_age is 200 million.
As the documentation for the function family you are using says:
The internal transaction ID type (xid) is 32 bits wide and wraps around every 4 billion transactions. However, these functions export a 64-bit format that is extended with an "epoch" counter so it will not wrap around during the life of an installation.

How do I compare two TIMESTAMP columns to check for a difference of at most 15 minutes?

I'm using PostGres 9.5. I have a column in my table, article, of type TIMESTAMP. I would like to write a query in which one of the conditions is to compare two articles whose dates are separated by at most 15 minutes. I tried this ...
where extract(minute from a2.created_on - a1.created_on) < 15
but I'm realizing this is incorrect. This returns articles separted by 15 minutes but also articles separated by an hour and 15 minutes and two hours, 15 minutes, etc. How do I refine my condition so that it only considers articles separated by 15 minutes?
It should be more simple:
WHERE a2.created_on - a1.created_on < '15min'
Difference of two timestamp values is a interval value.

Hide Total Row in Rep[orting services

I have a report with total lines after a show is being reported.
A show may run a week or several weeks. I want to hide the total line when there is only 1 week for the show but display the total line when there are more than one week. The example below should hide the Total row for "An American In Paris" but show for the other shows because they run for more than 1 week.I group by performance, week, start date.
I have tried:
=IIF(SUM(Fields!week_performance.Value)<=1,True,False)
and
=IIF((Fields!week_performance.Value)<=1,True,False)
neither seems to work, even if week = 1 the total line still shows
Performance week sales
A Gentlemens guide to Love & Murder 1 1500
2 2000
Total 3500
An American in Paris 1 1800
Total 1800
First Date 1 1900
2 2100
3 1800
Total 58000
I think what you need is the CountRows() function. In this case, using it as follows will default to the current scope (i.e., the group of the showing, in this case) and should count just 1.
=IIF(CountRows() = 1,true,false)
In addition to CountRows(), if you had some unique value per showing, you could use the following:
=IIF(CountDistinct(Fields!UniqueID.Value) = 1,true,false)
If this doesn't work, reply as a comment and I'll do my best to help.