Your code is rather weird.
You seem to have little understanding of the C# type system
You seem to try to calculate a start date/time by subtract some "age" from "now".
What is "age"? seconds, minutes, hours, days, weeks, monts, years, centuries, mayan-cycles ;-)...?
Anyways: when calculating with times, you need to understand the difference between
- a point in time
(like "now", "yesterday", "last year", etc.)
- and a duration
(like "1 hour", "20 years", etc.).
Durations can be added/subtracted from each other, resulting in a new duration.
Adding/subtracting two points in dime result in a durations.
Adding/subtracting a duration to/from a point in time gives a new point in time.
denotes a point in time.
denotes a duration.
In your code, I assume "age" to be a duration.
1) set the point in time variable "now" to
2) parse the "duration" input text into a
(you need to decide on the right unit)
3) subtract the "duration" from "now"
4) convert the result to the desired point in time format (e.g. year only) and assign that to your text output variable
PS: Strongly recommend to use
instead of any
methods. Reason: user input is potentially broken.