
PRO
dbeard
USA
Asked
— Edited

Has anyone a piece of script code that will calculate how many days have past since the current date? I need to do the calculation, but I believe the dates are alphanumeric and not numeric and cant figure it out.
What is a wolfram alpha? I am a beginner, trying to learn ez robot script language. I was hoping I could see an example of someone else's script language. But maybe no one has done anything like this before. I do appreciate your comments d.cochran but you are definitely an advanced user.
I have seen examples of this being done in c++ but not sure how to put it into script language. see below (partial code I found)
Days in-between dates
002 // Compiled in Visual C++ 2008 Express Edition
003 // Language: C++/STL
004
005
006 #include<iostream>
007
008 using namespace std;
009
010
011
012
013 int main()
014 {
015
016 int days_in_months[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
017
018 int first_day, second_day;
019
020 int first_month, second_month;
021
022 int first_year, second_year;
023
024 int years_difference, days_difference;
025
026 int months_total;
027
028 int reg_year = 365;
029
030
031
032 cout<<"Program to calculate how many days are in between the day/month/year entered."<<endl;
033 cout<<endl;
034
035 cout<<"Please enter the date by day, month, year."<<endl;
036 cout<<endl;
037
038 cout<<"First date:: "<<endl;
039 cout<<endl;
040
041 cout<<"Day: ";
042 cin>>first_day;
043 if(first_day > 31 || first_day <= 0)
044 {
045 cout<<"Incorrect day entered"<<endl;
046 cin.ignore();
047 return 0;
048 }
049 cout<<"Month: ";
050 cin>>first_month;
051 if(first_month > 12 || first_month <= 0)
052 {
053 cout<<"Incorrect Month entered"<<endl;
054 cin.ignore();
055 return 0;
056 }
057 cout<<"Year: ";
058 cin>>first_year;
059 if(first_year > 9999 || first_year < 0)
060 {
061 cout<<"Incorrect Year Entered"<<endl;
062 cin.ignore();
063 return 0;
064 }
065
066 cout<<endl;
067 cout<<"\nSecond date:: "<<endl;
068 cout<<endl;
069
070 cout<<"Day: ";
071 cin>>second_day;
072 if(second_day > 31 || second_day <= 0)
073 {
074 cout<<"Incorrect day entered"<<endl;
075 cin.ignore();
076 return 0;
077 }
078 cout<<"Month: ";
079 cin>>second_month;
080 if(second_month > 12 || second_month <= 0)
081 {
082 cout<<"Incorrect Month entered"<<endl;
083 cin.ignore();
084 return 0;
085 }
086 cout<<"Year: ";
087 cin>>second_year;
088 if(second_year > 9999 || second_year < 0)
089 {
090 cout<<"Incorrect Year Entered"<<endl;
091 cin.ignore();
092 return 0;
093 }
094
095
096 /////////////////////////////Years/////////////////////////////////
This code just sets up the parameters and then asks for the dates. It does some validation on the dates but doesn't do any calculations. I assume that the remainder of the code has been truncated?
correct. I wasn't going to paste the whole thing, just show an example of it being done through code.
Okay no worries. I just wanted to mention that the scripts in the birthday link don't just use years, but months as well, and using the date/time variables, you can also do days, hours, or minutes if desired. Can you give us an application example of what you would use this kind of script for, it might help give us to guide you better.
sure. I am going to use the calculation to determine how many days have gone past since a particular update. I can figure it out as long as it happens within the month. My problem is when the days go across a month how to figure it out. I have to calculate, what month, how many days in the month, etc...
Nothing to do with a calendar or birthdays. If the update is 2 days old I want to take one action if 3 days old another action. In no scenario do I see the elapsed time being over 3 days. so never months or years. I played around with it some, but cant figure out how to even compare one date to another, the script wants to treat the date as a alphanumeric, not numeric. so things line < > don't work at least for me.
hope that helps.
Okay thanks for that. That makes it a lot clearer to what you're looking to do. I won't be near a computer with ARC on it for a day or two, but when I get a chance I'll see if I can work something out for you, unless somebody else comes up with a solution of example in the mean time.
that works for me. thanks for your time.
Had to pick someone. But certainly Steve G. assisted.