duplo1
Posts: 67
|
Posted: 04/27/2009, 9:40 AM |
|
I need to calculate a date field for an Asp.net C# INMOTION project. The standard asp.net coding does not work, and Inmotion is not documented at all.
Here is what I would need:
When a registration field is completed, it should automatically calculate an expiration date based on Current Date + 30 Days.
I have tried:
Corporate_Addresses.GetControl<MTTextBox>("Plan_Expiration").Text = DateTime.Now.ToString() + 30;
I dont get an error, but the default value is displayed as "4/25/2009 8:11:21 PM30"
Anyhelp is much appreciated.
Christoph
|
|
|
vsuarez
Posts: 8
|
Posted: 04/27/2009, 10:30 AM |
|
Hi Christoph,
You are concatenating strings instead of adding days. To add days you may use something like:
theNewDate = DateTime.Now.AddDays(30);
In your example:
Corporate_Addresses.GetControl<MTTextBox>("Plan_Expiration").Text = DateTime.Now.AddDays(30).ToString();
If you want your new date not to fall in a holiday, you may also use something like:
while (theNewDate.DayOfWeek == DayOfWeek.Saturday || theNewDate.DayOfWeek == DayOfWeek.Sunday) {
theNewDate.AddDays(1);
}
Regards,
Victor
|
|
|
duplo1
Posts: 67
|
Posted: 05/04/2009, 9:59 AM |
|
Thank you so much, Victor.
It worked great.
C.
|
|
|
|