Count between Days



  • Hello All,

    Not that formiliar with OB yet. Just trying out. Is it possible when there is a aacount created en this will last for example 6 months to give the user a note like how many days left for his subscribtion will end. Thanks for any help in advance.



  • No one to assist...???


  • Mod

    I don't do too much loliscript you need the advice of someone who knows more but you can try IF MONTH < 2
    PRINT "subscription soon expired"
    Finally you have to look on your side too otherwise you will understand nothing



  • Hi there...Thanks for your reply...I try daily and search the internet for implenting codes for my config...Where should i put your line of code...



  • Actually what i want to try to achive is like this...subscription activated on 01-08-2020....Subscriptions ends on 21-08-2020 (20 days left for your subscription)...dont know if this is possible...any help would be very much appreciated...



  • @Hakka
    OB does not have a specific function to do that but you can play around with the huge flexibility that OB offer
    i'm sure there is a better way to do that, meanwhile use this, by the way take advantage of JavaScript Example 🙂

    #FUNCTION_Cap FUNCTION Constant "2020-08-27" -> VAR "MYCAPTUREDATE"  ## Input Format Date (FullYear-Month-Day)
    BEGIN SCRIPT JavaScript
    var date1 = new Date(MYCAPTUREDATE);
    var date2 = new Date();
    var dif = date1.getTime() - date2.getTime();
    var fdays = (Math.round(dif/ (1000*60*60*24)));
    END SCRIPT -> VARS "fdays"
    FUNCTION Constant "<MYCAPTUREDATE> (<fdays> days left for your subscription)" -> VAR "END_Subcription"  
    

    Result ------------------------------------------------------------------------------------->👇
    dayleft.PNG


  • Banned

    This post is deleted!


  • Hi Br4uN...That looks very nice...a question though...i have a field VAR Created and a field VAR Expiration...can i put the Created like <Created> where you put "2020-08-27" so it will effect every date what is in that field...andf what about the other field...very much appreciuated your help...



  • @Hakka
    yes you can, also you could jump farther, but need to take in consideration your capture format, should be (year-months-day)
    then you could replace var date1 = new Date(MYCAPTUREDATE); By---> var date1 = new Date(Created);



  • Thanks again Mate...Gonna let you know after implemented...



  • So..It would be like this...
    #FUNCTION_Cap FUNCTION Constant "<Created>" -> VAR "MYCAPTUREDATEA" ## Input Format Date (FullYear-Month-Day)
    #FUNCTION_Cap FUNCTION Constant "<Expire Date>" -> VAR "MYCAPTUREDATEB" ## Input Format Date (FullYear-Month-Day)

    BEGIN SCRIPT JavaScript
    var date1 = new Date(MYCAPTUREDATEA);
    var date2 = new Date(MYCAPTUREDATEB);
    var dif = date1.getTime() - date2.getTime();
    var fdays = (Math.round(dif/ (10006060*24)));
    END SCRIPT -> VARS "fdays"
    FUNCTION Constant "<MYCAPTUREDATE> (<fdays> days left for your subscription)" -> VAR "END_Subcription"


  • Mod

    yes like that @Hakka



  • Thanks Guys for your help...much appreciated...here is the output in Debugger...think something with the var fdays...

    Created (Single) = 2019-04-26T11:26:14.000Z
    Expire Date (Single) = 2021-04-27T11:04:00.000Z
    MYCAPTUREDATEA (Single) = 2019-04-26T11:26:14.000Z
    MYCAPTUREDATEB (Single) = 2021-04-27T11:04:00.000Z
    fdays (Single) = -732
    END_Subcription (Single) = <MYCAPTUREDATE> (-732 days left for your subscription)



  • I finaly got it working...had to change A to B for a good calculation...Again thanks to you Guys helping me around...


Log in to reply