Jump to content



Photo

How Do I Subtract Two Time Stamps To Get A Number Of Days


  • Please log in to reply
2 replies to this topic

#1 BigEfromDaBX

BigEfromDaBX

    Advanced Member

  • Members
  • PipPipPip
  • 285 posts
  • OS:Windows 8
  • Total Memory:< 1Gb
  • Framework:v3.5
  • License:Standard Edition

Posted 10 October 2017 - 02:29 PM

How do I subtract date1 - date2 = xdays?

 

date1 = 2017-06-26 00:00:00

date2 = 2017-06-25 00:00:00

 

If I subtract date1 - date2 it should be one day.

 

Thanks



#2 HelloInsomnia

HelloInsomnia

    Advanced Member

  • Moderators
  • 2577 posts
  • OS:Windows 10
  • Total Memory:More Than 9Gb
  • Framework:v4.5+, unsure
  • License:Developer Edition

Posted 10 October 2017 - 04:36 PM

How do I subtract date1 - date2 = xdays?

 

date1 = 2017-06-26 00:00:00

date2 = 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/f...me-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")

pGQyKlE.gif


#3 BigEfromDaBX

BigEfromDaBX

    Advanced Member

  • Members
  • PipPipPip
  • 285 posts
  • OS:Windows 8
  • Total Memory:< 1Gb
  • Framework:v3.5
  • License:Standard Edition

Posted 10 October 2017 - 06:52 PM

 

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/f...me-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.






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users