Skip to main content
Contributor I
Jul 30, 2022 9:43 AM UTC
Solved

Modulo - Generating a Random Number

Hiya, 

Is there anything like Modulo in Klaviyo/Django?

Something like this:

{% capture timeSeed %}{{ 'now' | date: "%s" }}{% endcapture %}{% assign random = timeSeed | modulo: 3 %}

The code uses the time to create a random number.

Thanks for your help.

    This topic has been closed for replies.
    Dov
    DovAnswer
    Klaviyo Alum
    Aug 1, 2022 3:43 PM UTC

    Hi @autotim,

    Thanks for sharing this question with us.

    We currently don’t have the ability to generate a random number using the time.

    Perhaps you can elaborate on the use case a bit further (what are you using the number for and if it needs to be based on time or can be truly random?) and we can look to find a viable alternative.

    Thanks for being a community member.

     

     

    DD

    1 reply

    Dov
    DovAnswer
    Klaviyo Alum
    Aug 1, 2022 3:43 PM UTC

    Hi @autotim,

    Thanks for sharing this question with us.

    We currently don’t have the ability to generate a random number using the time.

    Perhaps you can elaborate on the use case a bit further (what are you using the number for and if it needs to be based on time or can be truly random?) and we can look to find a viable alternative.

    Thanks for being a community member.

     

     

    DD