for example, now I want to encrypt my birthday 19960609, if I using some other format-preserving encryption, I will get a number that is not like a birthday. However, I want to my encrypted birthday like 19870928 which is in a specific field.
take birthday for example, the field is like [19000101,20191117].
I want to know is there any solution to encrypt one number to another number in a specific field, and this encrypted birthday could go back to the original value as well.
You might want to search for the term encoding. The string "19960609" is just an encoded representation of the date value 09/06/1996.
To give you an idea of an algorithm (a variation of ROT13):
// find the number of days between the start of your interval and the to be encoded date
a := COUNT_DAYS_BETWEEN(19960609, 19000101)
// find thesize of your interval
b := COUNT_DAYS_BETWEEN(19000101, 20191117)
// add or subtract a choosen number
c := a - 3567
// take care that it still fits into your interval
d := MODULO(c, b)
As the algorithm just shifts the birthday by some choosen days it's reversable. Feel free to replace the operation in c with a more complex algorithm.
Related
I have a DDB table, 4 attributes, key (PK - a string), date (sort/range key), status, frequency.
I have multiple clients that will write to this table based on the 'key' and date value
I want to increment frequency every time a client makes a write.
Can I just use DynamoDBVersionAttribute on an int field and use this as a proxy for frequency?
I understand this is not meant for this use case, but I want to avoid having to first read and then write the item. Any thoughts?
Since you're already doing an update expression, just add an ADD action to increment the frequency by 1. The ADD action doesn't need to know the original value to increment it.
See the example from the docs here:
https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.UpdateExpressions.html#Expressions.UpdateExpressions.SET.IncrementAndDecrement
So I want to specify a time after which a post gets deleted. The time is 3 months, in my code I would define this as
const THREE_MONTHS_IN_MS = 7889400000
export const TIME_AFTER_WHICH_USER_IS_DELETED = THREE_MONTHS_IN_MS
How can I define this in my database without resorting to the use of a magic number? Basically it looks like this right now:
timeAfterWhichUserIsDeleted: 7889400000
Or as a direct screenshot of the database: https://gyazo.com/67abfdc329e1e36aae4e66b0da4b4f75
I would like to avoid this value in the database and instead have it be more readable.
Any tips or suggestions?
The 7889400000 is a UNIX timestamp, indicating a number of milliseconds since the epic. While you can store a value indicating the same moment in a different format, you'll want to make sure that the format you use still allows you to query the value.
A common format that is both readable and queryable it ISO-8859-1, and my current time in that format would be 2022-03-22 06:50:48.
I noticed after re-reading your question that your timeAfterWhichUserIsDeleted is actually an interval and not a moment. If the interval is always going to be in months, you could store countOfMonthsAfterWhichUserIsDeleted: 3 as a more readable form of the same intent. Just note that 3 is equally magic as 7889400000 and the main difference is that I've named the field more meaningfully.
Introduction
Many sites use WooCommerce as a plugin for their WordPress site and so do we :). We've linked all purchases to google sheets, so I can do some analyses.
Our goal is get a many children physically active as we can and we have gym classes for very young children with they parents. To teach them the basics of the fun of physical activity
What I would like to do
I would like to know, how many free trial classes actually convert to paying customers and what the average timespan is between booking a trial class and becoming a member
The data that I have
I have the following columns which are necessary for this, I believe:
Datestamp
paymentID (is empty when booking a free trial class)
Price (is 0,00 whem booking a free trial class)
childsName (Unique in combination with parentsEmailadress, but recurs every month in the list once a membership is active)
parentsEmailadress (may have several children)
OrderName (has the string "trial" or "Membership")
I've made some dummy data in the following sheet:
https://docs.google.com/spreadsheets/d/1lWzQbXMU4qRLp_2qiQ_qsq57nPMy2RG8AHDMGKW626E/edit?usp=sharing
Possible solution
My guess is that I should:
make a column in which I combine the childs name and the emailadress
Make a TRUE of FALSE column to check if order is trial class or not
Make a column to find the first Unique child-emailadres combination in previous orders (How do I do that?! - Vlookup?)
and than
if this is found than check again if this is a trial class order.
If it is a trial class order than it should determine the amount of days between the trial class order and the non-trial class order and display the amount of days
if this is another normal order than leave empty(it's just a membership order)
if the emailadres is not found than display "direct" (it's a directly bought membership)
I did 1 and 2 and tried 3 with:
=ALS(H2=0;VERT.ZOEKEN(G2;A:G;1;ONWAAR);) (in Dutch)
=IF(H2=0;V.LOOKUP(G2;A:G;1;FALSE);) (possible translation)
But this doesn't work.
Really hope some can point me in the right direction!
Thank you very much in advance!
Given that trial classes have a price of 0, there's no need to create another column to identify those cases–just check the price. To the source data we'll add the "Client ID" column that you created in Column G of your sample sheet. (Ideally, you'll come up with an client ID system, but this works.) Now, create a new sheet that will be your dashboard and let's add a few columns:
Client ID This grabs only the unique values from the Client IDs in Sheet2 as we don't want users to be repeated in our dashboard. (Column A, row 1... for all others place the formulas in row 2).
=UNIQUE(Sheet2!G:G)
Did they trial? This will tell you TRUE/FALSE if the client did a trial. (Column B).
=ISNUMBER(MATCH(Dashboard!A2, FILTER(Sheet2!G:G, Sheet2!C:C=0), 0))
Did they convert? This will tell you TRUE/FALSE if the client converted from trial to paid. (In cases where they did not do a trial, it will be blank.) (Column C).
=IF(Dashboard!B2, ISNUMBER(MATCH(Dashboard!A2, FILTER(Sheet2!$G:$G, Sheet2!$C:$C>0), 0)), "")
Date of First Trial The date of the first trial. If none exists, will be blank. (Column D).
=IFERROR(MIN(FILTER(Sheet2!$A:$A, Sheet2!$G:$G=Dashboard!A2, Sheet2!$C:$C=0)))
Date of First Paid Course The date of the first paid course. If none exists, will be blank. (Column E).
=IFERROR(MIN(FILTER(Sheet2!$A:$A, Sheet2!$G:$G=Dashboard!A2, Sheet2!$C:$C>0)))
Days from First Trial to First Paid The number of days between the first paid course and the first trial course. If one of those values doesn't exist, then will be blank. (Column F).
=IF(ISDATE(Dashboard!E2), Dashboard!E2-Dashboard!D2, "")
Now you can answer several questions:
How many clients used a free trial? =COUNTIF(Dashboard!B:B, TRUE)
How many free trials converted? =COUNTIF(Dashboard!C:C, TRUE)
Average number of days from first trial to first paid? =AVERAGE(Dashboard!F:F)
I'm making a report that involves Tours lets say. I have one column populated by the tour_start_time datafield and another populated by tour_end_time. Then i have a column called Total Time. The Total Time column needs to tell me in hh:mm format what the difference between tour_start_time and tour_end_time is. So if tour_start_time returned 5:00 and tour_end_time returned 5:06 then Total Time should be 0:06. I can't seem to get this and the DateDiff stuff I've read all reference Parameters which isn't what I'm using. I need the data in a table. I tried this expression:
=DateDiff(minute,Fields!tour_start_time,Fields!tour_end_time)
But that didn't work and neither did any of the variants of that which I tried. I know im missing something as im new to this so sorry if it's a dumb question but i need someone that can explain it to me or at least give me another function to try.
Assuming your columns are actually DateTime data types, your DateDiff expression should look like this:
=DateDiff(DateInterval.Minute, Fields!tour_start_time.Value, Fields!tour_end_time.Value)
or
=DateDiff("n", Fields!tour_start_time.Value, Fields!tour_end_time.Value)
VB.NET DateDiff requires a DateInterval parameter; you can either specify the enumerator member (DateInterval.Minute) or its string representation (i.e. "n" for minute).
This will only return an integer value for the difference in minutes; it sounds like you need to then change this to a HH:mm string. Off the top of my head the easiest way to do this would be with some custom code in the report which takes this integer value as a parameter and construct the string based on this. Let me know if you need more information for this part.
I'm trying to do a formula in Infopath:
Say i have 3 fields called singles, 10's and 25's.
I also have another field where the user typed in a number.
If the user types in 15 for example, this should fill in the 10's filed with 1, and the singles field with 5.
If the user typed 49 into the field, then the 25's would be filled with 1, the 10's with 2, and the singles with 4.
If they type in 50, then the 25's field will be filled with 2.
Does anyone have any idea where I could start in doing this?
Many thanks in advance.
Jason
Here is the basics of the solution (which was quickly verified in IP). I leave the math specifics up to you just in case this is a HW problem. If you have specific troubles post back and we can help.
Set a rule on your input field with no conditions so it will fire anytime the field changes.
Use the number function on a field to be able to use it in calculations. Infopath doesn't have a mod function so do divide with floor and subtraction.
Create an action for each amount (making sure to order them by highest first).
So for example your 25s field action would be floor(number(inputfield) / 25).
Your 10s action would be floor(number(inputfield) - number(25sfield) * 25) / 10).
Etc for each one (and note that the ones field is just whatever is leftover - no divide or floor needed).