1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

How to get the end of Second's number?

Discussion in 'C#' started by JJnacy, Jun 5, 2009.

  1. #1
    Example now is
    6/4/2009-4:51:37-PM

    I just want to get the 7 of the 37 as a random number.

    How to do it?


    Thanks,
    SEMrush
     
    JJnacy, Jun 5, 2009 IP
    SEMrush
  2. JJnacy

    JJnacy Peon

    Messages:
    448
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #2
    I found this one.

    <%= right(FormatDateTime(Now(), 4),1) %>

    Any other to do the job?
     
    JJnacy, Jun 5, 2009 IP
  3. camjohnson95

    camjohnson95 Active Member

    Messages:
    737
    Likes Received:
    17
    Best Answers:
    0
    Trophy Points:
    60
    #3
    What is the purpose of this? Why would you not just use the random number generator to generate a number between 0-9 ?

    But another way to do what you want (in asp.net) :
    
    <%= Right(Now.Second.ToString, 1) %>
    
    Code (markup):
     
    camjohnson95, Jun 8, 2009 IP
  4. JJnacy

    JJnacy Peon

    Messages:
    448
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Thanks again,
    Because, I am trying to make a random to go with time's parts so I can know the "when".

    My example question here http://forums.digitalpoint.com/showthread.php?p=11639417#post11639417
    Hope you can me too.

    BTW, <%= Right(Now.Second.ToString, 1) %>
    It is not working and has an error appear.

    Regards,
     
    JJnacy, Jun 10, 2009 IP
  5. camjohnson95

    camjohnson95 Active Member

    Messages:
    737
    Likes Received:
    17
    Best Answers:
    0
    Trophy Points:
    60
    #5
    Yeh, I take it that you are using Classic ASP then.
     
    camjohnson95, Jun 11, 2009 IP
  6. dopanel.com

    dopanel.com Peon

    Messages:
    94
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #6
    
      right(second(now),1)
    
    Code (markup):
     
    dopanel.com, Jun 14, 2009 IP
  7. JJnacy

    JJnacy Peon

    Messages:
    448
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Thanks,

    How come I did know this one. So easy and so simple.
     
    JJnacy, Jun 14, 2009 IP
  8. workhomer

    workhomer Peon

    Messages:
    4
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #8
    If it's asp.net you may want to use the .NET methods for manipulating strings instead right/left and such.
     
    workhomer, Jun 15, 2009 IP
    JJnacy likes this.
  9. DoDo Me

    DoDo Me Peon

    Messages:
    2,258
    Likes Received:
    27
    Best Answers:
    0
    Trophy Points:
    0
    #9
    function $random(min, max, radix){
    if(radix){ // if radix>0, then generete string, that contains 0-9a-z(0-35) set by radix(1-35), from min len to max len
    r = radix;
    if(r<1)r=1;
    if(r>35)r=35;
    a = ['0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'];
    l=(min==max)?min:$random(min, max);
    s='';
    for(var i=1;i<=l;i++){
    s+=a[$random(0, r)];
    }
    return s;
    }else{ // ToDO: use CryptGenRandom for true random
    return Math.floor(Math.random() * (max - min + 1) + min);
    }
    }
     
    DoDo Me, Jun 17, 2009 IP
    JJnacy likes this.
  10. janticlaudinef

    janticlaudinef Peon

    Messages:
    26
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #10
    Because who are going to make increases in row three will be adding four stittches there are diffrent ways to make increases who can use the way use in pattem.
     
    janticlaudinef, Jun 24, 2009 IP