What the heck does this mean:
error CS0019: Operator -' cannot be applied to operands of type System.DateTime’ and `string’
I’m trying to use it like this:
public static string GetDaysPassedQ01()
{
LoadInformation.LoadStartDateQ01 ();
Debug.Log(StartDateQ01);
today = System.DateTime.Now;
System.DateTime compareDate = today; //.AddDays(0);
System.TimeSpan difference;
difference = compareDate - today;
difference = compareDate - StartDateQ01;
//difference = today - startDate;
Debug.Log("Days Passed: " + difference.Days);
return difference.Days.ToString();
}
NOTE: The Debug.Log(StartDateQ01); shows this:
01/05/2017 14:04:48
UnityEngine.Debug:Log(Object)
difference = compareDate - today;
difference = compareDate - StartDateQ01;
That’s where the error is going on… “today” and / or “StartDataQ01” is being stored in a string, so what the computer thinks your doing is taking a number and subtracting some text from it, which isn’t possible…
My suggestion is to make sure that they all are being stored in the same variable way, and if you want to subtract them, you will have to turn them into System.DateTime (if you can use operators with those)…
What I would do (which is most likely the least energy efficient way) is to convert both bools into numbers 1 - 366 * year , and then after subtracting what I need, I would just convert them to the regular form… Which itself would take some extensive coding