Wednesday, March 28, 2012

subtracting days from date

hI,
i AM TRYING TO SUBTRACT DAYS FROM PARTICULAR DATE. i KEEP GETTING THE ERROR:
hERE IS MY CODE: enddatecriteria=tempDate.AddDays(30);
startdatecriteria=tempDate.AddDays(-30);
I AM USING C# AND THE ERROR IS:
Ticks must be between DateTime.MinValue.Ticks and DateTime.MaxValue.Ticks.
Parameter name: ticks
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information abou
t
the error and where it originated in the code.
Exception Details: System.ArgumentOutOfRangeException: Ticks must be between
DateTime.MinValue.Ticks and DateTime.MaxValue.Ticks. Parameter name: ticks
Source Error:
cAN SOMEONE HELPtempDate = System.DateTime.Now;
enddatecriteria=tempDate.AddDays(30);
startdatecriteria=tempDate.AddDays(-30);
"Manny Chohan" wrote:

> hI,
> i AM TRYING TO SUBTRACT DAYS FROM PARTICULAR DATE. i KEEP GETTING THE ERRO
R:
> hERE IS MY CODE: enddatecriteria=tempDate.AddDays(30);
> startdatecriteria=tempDate.AddDays(-30);
> I AM USING C# AND THE ERROR IS:
> Ticks must be between DateTime.MinValue.Ticks and DateTime.MaxValue.Ticks.
> Parameter name: ticks
> Description: An unhandled exception occurred during the execution of the
> current web request. Please review the stack trace for more information ab
out
> the error and where it originated in the code.
> Exception Details: System.ArgumentOutOfRangeException: Ticks must be betwe
en
> DateTime.MinValue.Ticks and DateTime.MaxValue.Ticks. Parameter name: ticks
> Source Error:
> cAN SOMEONE HELP
my complete code is follows:
tempDate=Convert.ToDateTime(Calendar2.TodaysDate.ToShortDateString());
enddatecriteria=tempDate.AddDays(30);
startdatecriteria=tempDate.AddDays(-30);
It still give me error. I am using c#.
Thanks
Manny
"vinay" wrote:
> tempDate = System.DateTime.Now;
> enddatecriteria=tempDate.AddDays(30);
> startdatecriteria=tempDate.AddDays(-30);
>
> "Manny Chohan" wrote:
>
Which event are you checking the values'
post the full code.
"Manny Chohan" wrote:
> my complete code is follows:
> tempDate=Convert.ToDateTime(Calendar2.TodaysDate.ToShortDateString());
> enddatecriteria=tempDate.AddDays(30);
> startdatecriteria=tempDate.AddDays(-30);
> It still give me error. I am using c#.
> Thanks
> Manny
> "vinay" wrote:
>
thanks Vinay, here is the code:
if(!Page.IsPostBack)
{
Get_Appointments();
tempDate=Convert.ToDateTime(Calendar2.TodaysDate.ToShortDateString());
}
public void MonthChanged(object sender, MonthChangedEventArgs e)
{
//Set the tempDatevariable to the value in the MonthChangedEventArgs
NewDate property
tempDate = e.NewDate;
//Reload the collection
Get_Appointments();
}
ICollection Get_Appointments()
{
DateTime startDate = new DateTime(2004,11,1);
DateTime endDate = new DateTime(2004,12,1);
enddatecriteria=tempDate.AddDays(30);
startdatecriteria=tempDate.AddDays(-30);
Rest follows the custom code as i am working with vendor API. Please let me
know if this is enough.
Thanks
Manny
"vinay" wrote:
> Which event are you checking the values'
> post the full code.
> "Manny Chohan" wrote:
>
Manny, looks like your tempdate is empty when you do the startdatecriteria=
(you're trying to back off 30 days from what's already the date.minvalue).
I'd trace backwards from there and look at calendar2.todaysdate and
e.newdate. hth
"Manny Chohan" wrote:
> thanks Vinay, here is the code:
> if(!Page.IsPostBack)
> {
> Get_Appointments();
> tempDate=Convert.ToDateTime(Calendar2.TodaysDate.ToShortDateString()
);
> }
> public void MonthChanged(object sender, MonthChangedEventArgs e)
> {
> //Set the tempDatevariable to the value in the MonthChangedEventArgs
> NewDate property
> tempDate = e.NewDate;
> //Reload the collection
> Get_Appointments();
> }
> ICollection Get_Appointments()
> {
> DateTime startDate = new DateTime(2004,11,1);
> DateTime endDate = new DateTime(2004,12,1);
> enddatecriteria=tempDate.AddDays(30);
> startdatecriteria=tempDate.AddDays(-30);
> Rest follows the custom code as i am working with vendor API. Please let m
e
> know if this is enough.
> Thanks
> Manny
>
> "vinay" wrote:
>

0 comments:

Post a Comment