Skip to main content
Contributor I
July 30, 2022
Solved

Modulo - Generating a Random Number

  • July 30, 2022
  • 1 reply
  • 211 views

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.
    Best answer by Dov

    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.

     

     

    1 reply

    Dov
    DovAnswer
    Klaviyo Alum
    August 1, 2022

    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