-2

How do i go about writing some basic algebra math in vb.net?

Example:

I need to schedule a process to run 60 days before start date of an object.

When my process runs I do:

Now(UTC) - StarDate(UTC) = days diff

If days diff less than 60, i run my process immediately.

If its over 60 days, i need to schedule my process to run again in 60 days.

So this leaves me with:

X - [daysDiff] = 60

I know how to solve this on paper but not in vb.net code.

Example:

X - 107 = 60

add 107 to each side, i have my # of days to add (107)

How do i accomplish this in VB.net?

LarsTech
  • 80,625
  • 14
  • 153
  • 225
BKBK
  • 21
  • 3
  • Are you asking how to write code that solves an arbitrary equation at runtime, or how to solve this specific equation? – SLaks Sep 07 '18 at 15:59
  • I am not exactly sure, sorry i don't know the correct terminology. Basically i need to solve for X so i know how many days to add to now(utc) when i schedule my process to run again so it runs 60 days before the start date. I know to solve this on paper you would add the non X value to each side of the equation then you end up with your answer for X. So solution for X - 107 = 60 is 167. – BKBK Sep 07 '18 at 16:02
  • 1
    Do that algebra your self, to convert it into a simple expression (`60 + daysDiff = X`) – SLaks Sep 07 '18 at 16:04
  • This is covered in [Solving One-Step Equations Using Properties of Equality](http://www.montereyinstitute.org/courses/DevelopmentalMath/COURSE_TEXT2_RESOURCE/U10_L1_T1_text_container.html). – Andrew Morton Sep 07 '18 at 19:14

1 Answers1

0

If you want to know when to run it: if it's over 60 days, then subtract 60 from that value, that will tell you when when to check again.... so if you do the initial check and it comes back 61 days different, it's over 60, so you subtract 60, leaving 1. So now you know you need to schedule it in 1 day. If you do the initial check and it comes out 107, you subtract 60 and the result is 47... so you know in 47 days, you need to run it again as that will be 60 days out. It's two simple steps.

TechGnome
  • 195
  • 1
  • 11