Mixpanel Community Icon

Creating a Custom Property to Subtract One Day from Time Field

·
·

Is it possible to create a custom property that subtracts one day from the “Time” field?

  • Avatar of kapa.ai
    kapa.ai
    APP
    ·
    ·

    Hi Asaf Y., Please stand by as I search the Mixpanel knowledge base for an AI-powered answer. I normally take about 15 seconds or so. In case AI cannot answer your question, feel free to reach out to Mixpanel support at mixpanel.com/get-support. If you have follow-up questions for this thread, please tag me again with your question: @kapa.ai <follow-up question> 👋

    Feel free to ask a follow-up question once I've answered by mentioning me with @kapa.ai

  • Avatar of kapa.ai
    kapa.ai
    APP
    ·
    ·

    Yes, it is possible to create a custom property that subtracts one day from the "Time" field in Mixpanel. You can achieve this using the custom properties feature and the datedif function.Here's how you can create such a custom property:1. Go to the custom property builder. 2. In the formula field, you can use the datedif function along with the "Time" property. 3. The formula would look something like this:LBKSdatedif(Time, TODAY(), "D") - 1LBKSThis formula calculates the difference in days between the "Time" field and today, then subtracts 1 day from that result.You can also use other time-related functions and operators to manipulate dates as needed. For more details on creating custom properties and available functions, you can refer to the Custom Properties documentation.Remember that custom properties allow you to combine existing properties into new properties on the fly, using a simple Excel-like formula language. This gives you flexibility in creating time-based calculations and other custom metrics as needed for your analysis.

    kapa.ai is still learning and improving, please let me know how I did by reacting below.

    ℹ️ Tip: Mention @kapa.ai in the thread for follow-ups or DM the app for 1-to-1 help.

  • Avatar of Asaf Y.
    Asaf Y.
    ·
    ·

    kapa.ai I want for example for the value ‘2024-12-25’ the result will be ‘2024-12-24’

  • Avatar of kapa.ai
    kapa.ai
    APP
    ·
    ·

    Let me check the knowledge base for you again. One moment! 📚

  • Avatar of kapa.ai
    kapa.ai
    APP
    ·
    ·

    To achieve the result you're looking for, where '2024-12-25' becomes '2024-12-24', you can use a combination of functions in Mixpanel's custom property feature. Here's how you can create a custom property that subtracts one day from a given date:1. First, you'll need to use the datedif function to subtract one day from the date. 2. Then, you'll need to format the result back into a date string.Here's an example of how you might construct this custom property:LBKSlet( original_date, Time, let( one_day_before, datedif(original_date, original_date, "D") - 1, format_date(original_date, "yyyy-MM-dd", one_day_before) ) )LBKSThis formula does the following: 1. It uses the let function to assign the original date (assuming it's in the "Time" field) to a variable. 2. It then uses datedif to subtract one day. 3. Finally, it uses format_date to format the result back into a "yyyy-MM-dd" string.Please note that this is a conceptual example, and the exact syntax might need to be adjusted based on Mixpanel's specific implementation of these functions.For the most up-to-date and accurate information on creating custom properties with date manipulations, I recommend checking the Custom Properties documentation and the Functions reference in Mixpanel's documentation.If you need further assistance or if this doesn't precisely meet your needs, you might want to reach out to Mixpanel's support team for more specific guidance on complex date manipulations in custom properties.

    kapa.ai is still learning and improving, please let me know how I did by reacting below.

    ℹ️ Tip: Mention @kapa.ai in the thread for follow-ups or DM the app for 1-to-1 help.