BigEfromDaBX 25 Posted October 10, 2017 Report Share Posted October 10, 2017 How do I subtract date1 - date2 = xdays? date1 = 2017-06-26 00:00:00date2 = 2017-06-25 00:00:00 If I subtract date1 - date2 it should be one day. Thanks Quote Link to post Share on other sites
HelloInsomnia 1103 Posted October 10, 2017 Report Share Posted October 10, 2017 How do I subtract date1 - date2 = xdays? date1 = 2017-06-26 00:00:00date2 = 2017-06-25 00:00:00 If I subtract date1 - date2 it should be one day. Thanks Typically with time you want to convert it to unix time and then work with it in this case you can convert it, subtract to get the difference and then divide that by 86400 (one day in seconds). You can use this plugin: http://ubotdev.com/free-plugin-datetime-manipualtion This will basically do that and round it using the ubot round function (which rounds to 2 places) if you want to a whole number you can use javascript. set(#date1,$plugin function("DateTime Manipulation.dll", "$datetime manipulation", "2017-06-26 00:00:00", "yyyy-MM-dd HH:mm:ss", "UNIX", "en-US", "en-US"),"Global") set(#date2,$plugin function("DateTime Manipulation.dll", "$datetime manipulation", "2017-06-25 00:00:00", "yyyy-MM-dd HH:mm:ss", "UNIX", "en-US", "en-US"),"Global") set(#differenceInSeconds,$absolute value($subtract(#date1,#date2)),"Global") set(#difference,$round($divide(#differenceInSeconds,86400)),"Global") 2 Quote Link to post Share on other sites
BigEfromDaBX 25 Posted October 11, 2017 Author Report Share Posted October 11, 2017 Typically with time you want to convert it to unix time and then work with it in this case you can convert it, subtract to get the difference and then divide that by 86400 (one day in seconds). You can use this plugin: http://ubotdev.com/free-plugin-datetime-manipualtion This will basically do that and round it using the ubot round function (which rounds to 2 places) if you want to a whole number you can use javascript. set(#date1,$plugin function("DateTime Manipulation.dll", "$datetime manipulation", "2017-06-26 00:00:00", "yyyy-MM-dd HH:mm:ss", "UNIX", "en-US", "en-US"),"Global") set(#date2,$plugin function("DateTime Manipulation.dll", "$datetime manipulation", "2017-06-25 00:00:00", "yyyy-MM-dd HH:mm:ss", "UNIX", "en-US", "en-US"),"Global") set(#differenceInSeconds,$absolute value($subtract(#date1,#date2)),"Global") set(#difference,$round($divide(#differenceInSeconds,86400)),"Global") Dude your the best. Hopefully Irma was good to you Thanks. 1 Quote Link to post Share on other sites
kill3rbko 12 Posted February 5, 2021 Report Share Posted February 5, 2021 (edited) On 10/10/2017 at 11:36 PM, HelloInsomnia said: You can use this plugin: http://ubotdev.com/free-plugin-datetime-manipualtion Hello, i have updated ubot to 6.3.9 and lost all my free plugins. This link is not valid anymore; By any chance is there a link for free plugins? Thanks in advanced! Edit : nvm im really a dumb! just seen im in plugins section! shame on me. Sorry Edited February 5, 2021 by kill3rbko Im a dumb Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.