How does this statement tell us if a user is active or not active?

Question

In the context of this exercise, how does this statement tell us if a user is active or not_active?

Answer

This statement tells us if a user is active or not active based on conditions.

First, it will check whether the purchase date of the premium plan is earlier than or equal to the current date. If it is not, then there might have been some error or they are not yet signed up.
premium_users.purchase_date <= months.months

Second, it will check whether either of the following conditions is true:

If the user’s cancel date is the current date or is planned for the future, this means that they are still under the plan until their cancel date arrives,
premium_users.cancel_date >= months.months

Or, if the user has no cancel date yet, this means that they did not cancel nor plan to cancel,
premium_users.cancel_date is NULL.

If the first condition and either of the second conditions is true, this must mean they are still active. Otherwise, they are not_active.

8 Likes

Are you Assuming that if he is only active for the “whole month” of January that he is active in January and if not he is not active. This is fallacious reasoning in part cuz if someone is active for even one day during Jan I would consider them active during Jan not inactive.

1 Like

I agree with board3405145664’s comment!

To rectify i think in the first condition of “premium_users.purchase_date <= months.month”, we could add an or “strftime(“m%”, premium_users.purchase_date) = strftime(”%m", months.month) to also include situations where some users were active for only part of the month or starting not exactly on the first date of month.

1 Like

I agree with @board3405145664. I think the most important thing is to define what’s mean active.
If you select months.months for a datum mark. When (premium_users.purchase_date <= months.months, premium_users.cancel_date >= months.months OR premium_users.cancel_date is NULL)it’s true, it means active.
But if not like this. When (premium_users.purchase_date > months.months, premium_users.cancel_date >= months.months OR premium_users.cancel_date is NULL) it’s true, it also means active.

1 Like

I think the code is valid because months.months is just 1st date of month like Jan. 1st or Feb. 1st