You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user-cs@ibatis.apache.org by Rahul Singh <an...@gmail.com> on 2004/12/29 23:17:49 UTC

issues with datetime as model properties.

"The statement has been terminated. Arithmetic overflow error
converting expression to data type datetime. "

How do you guys deal with DateTime values as your object properties?
I'm getting this error when I try to insert the object.

Rahul

Re: issues with datetime as model properties.

Posted by Rahul Singh <an...@gmail.com>.
I changed my insert statement to use "GETDATE()" wherever I was
inserting a property value and it worked.

As far as the date time formats go, they seem to be the same. 

Rahul 


On Fri, 31 Dec 2004 00:16:44 -0500, roberto <ro...@theaegis.org> wrote:
> Rahul,
> 
> Not sure if this will help, but just some suggestions to see what may be
> happening.
> 
> What is the expected date time format for the database that you are using?
> Perhaps you could try storing the DateTime field in a varchar column to see
> what format is being generated to compare to the expected database format?
> If they don't match, the database settings could be changed to accept the
> format being generated by the app or a conversion could be done in the SQL
> statement or the system settings where the app is running could be changed
> (the system may be formatting dates as yy/mm/dd but the database may be set
> to use mm/dd/yy for example...happens frequently with Oracle and the
> language settings).
> 
> Roberto 
> 
> 
> -----Original Message-----
> From: Rahul Singh [mailto:anantatman@gmail.com]
> Sent: Thursday, December 30, 2004 11:27 PM
> To: ibatis-user-cs@incubator.apache.org; rahul.singh@anant.us
> Subject: Re: issues with datetime as model properties.
> 
> I've tried hardcoding the values to be DateTime.MinValue, and I still
> get the same error. I am using the OleDB provider.
> 
> Rahul
> 
> On Thu, 30 Dec 2004 18:53:15 -0500, Ted Husted <hu...@apache.org> wrote:
> > Actually, I've never seen an arithmetic overflow error before.
> >
> > Is it possible that your timer values are going past DateTime.MaxValue ?
> >
> > -Ted.
> >
> > On Thu, 30 Dec 2004 17:37:52 -0500, Rahul Singh wrote:
> > > Ted,
> > >
> > > I think i know where you are coming from, but let's say I have this
> > > representing my properties in my model, what changes would you make
> > > to make this work? I think I may be having a senile moment, but i'd
> > > greatly appreciate your help.
> > >
> > > Rahul
> > >
> > > "
> > > protected DateTime _lastTimerStart;
> > > protected DateTime _lastTimerStop;
> > >
> > > public DateTime LastTimerStart
> > > {
> > > get {return _lastTimerStart;}
> > > set {_lastTimerStart = value;}
> > > }
> > >
> > > public DateTime LastTimerStop
> > > {
> > > get {return _lastTimerStop;}
> > > set {_lastTimerStop = value;}
> > > }"
> > >
> > >
> > > On Thu, 30 Dec 2004 07:21:02 -0500, Ted Husted <hu...@apache.org>
> > > wrote:
> > >
> > >> On Wed, 29 Dec 2004 17:17:49 -0500, Rahul Singh wrote:
> > >>
> > >>> "The statement has been terminated. Arithmetic overflow error
> > >>> converting expression to data type datetime. "
> > >>>
> > >>> How do you guys deal with DateTime values as your object
> > >>> properties? I'm getting this error when I try to insert the
> > >>> object.
> > >>>
> > >>> Rahul
> > >>>
> > >> At the moment, I have the model object convert the value back and
> > >> forth between a string representation and a binary
> > >> representation. The model object has a separate property for the
> > >> string representation that do the conversion and pass the binary
> > >> to the actual Date property. (So there is no private string
> > >> field, just the binary.) The data access methods use the binary
> > >> property. The controls use the string property.  The string
> > >> methods also watch for the magic null strings, and return blanks
> > >> to the controls.
> > >>
> > >> Next, I'm going to refactor for the Spring Framework, which I
> > >> believe has a lot of conversion utilities built in. Spring is
> > >> widely used by the Java community, and I expect we'll find the
> > >> same on the .NET side soon.
> > >>
> > >> [http://www.springframework.net/]
> > >>
> > >> -Ted.
> >
> >
> 
>

RE: issues with datetime as model properties.

Posted by roberto <ro...@theaegis.org>.
Rahul,

Not sure if this will help, but just some suggestions to see what may be
happening.

What is the expected date time format for the database that you are using?
Perhaps you could try storing the DateTime field in a varchar column to see
what format is being generated to compare to the expected database format?
If they don't match, the database settings could be changed to accept the
format being generated by the app or a conversion could be done in the SQL
statement or the system settings where the app is running could be changed
(the system may be formatting dates as yy/mm/dd but the database may be set
to use mm/dd/yy for example...happens frequently with Oracle and the
language settings).

Roberto 



-----Original Message-----
From: Rahul Singh [mailto:anantatman@gmail.com] 
Sent: Thursday, December 30, 2004 11:27 PM
To: ibatis-user-cs@incubator.apache.org; rahul.singh@anant.us
Subject: Re: issues with datetime as model properties.

I've tried hardcoding the values to be DateTime.MinValue, and I still
get the same error. I am using the OleDB provider.

Rahul


On Thu, 30 Dec 2004 18:53:15 -0500, Ted Husted <hu...@apache.org> wrote:
> Actually, I've never seen an arithmetic overflow error before.
> 
> Is it possible that your timer values are going past DateTime.MaxValue ?
> 
> -Ted.
> 
> On Thu, 30 Dec 2004 17:37:52 -0500, Rahul Singh wrote:
> > Ted,
> >
> > I think i know where you are coming from, but let's say I have this
> > representing my properties in my model, what changes would you make
> > to make this work? I think I may be having a senile moment, but i'd
> > greatly appreciate your help.
> >
> > Rahul
> >
> > "
> > protected DateTime _lastTimerStart;
> > protected DateTime _lastTimerStop;
> >
> > public DateTime LastTimerStart
> > {
> > get {return _lastTimerStart;}
> > set {_lastTimerStart = value;}
> > }
> >
> > public DateTime LastTimerStop
> > {
> > get {return _lastTimerStop;}
> > set {_lastTimerStop = value;}
> > }"
> >
> >
> > On Thu, 30 Dec 2004 07:21:02 -0500, Ted Husted <hu...@apache.org>
> > wrote:
> >
> >> On Wed, 29 Dec 2004 17:17:49 -0500, Rahul Singh wrote:
> >>
> >>> "The statement has been terminated. Arithmetic overflow error
> >>> converting expression to data type datetime. "
> >>>
> >>> How do you guys deal with DateTime values as your object
> >>> properties? I'm getting this error when I try to insert the
> >>> object.
> >>>
> >>> Rahul
> >>>
> >> At the moment, I have the model object convert the value back and
> >> forth between a string representation and a binary
> >> representation. The model object has a separate property for the
> >> string representation that do the conversion and pass the binary
> >> to the actual Date property. (So there is no private string
> >> field, just the binary.) The data access methods use the binary
> >> property. The controls use the string property.  The string
> >> methods also watch for the magic null strings, and return blanks
> >> to the controls.
> >>
> >> Next, I'm going to refactor for the Spring Framework, which I
> >> believe has a lot of conversion utilities built in. Spring is
> >> widely used by the Java community, and I expect we'll find the
> >> same on the .NET side soon.
> >>
> >> [http://www.springframework.net/]
> >>
> >> -Ted.
> 
>



Re: issues with datetime as model properties.

Posted by Rahul Singh <an...@gmail.com>.
I've tried hardcoding the values to be DateTime.MinValue, and I still
get the same error. I am using the OleDB provider.

Rahul


On Thu, 30 Dec 2004 18:53:15 -0500, Ted Husted <hu...@apache.org> wrote:
> Actually, I've never seen an arithmetic overflow error before.
> 
> Is it possible that your timer values are going past DateTime.MaxValue ?
> 
> -Ted.
> 
> On Thu, 30 Dec 2004 17:37:52 -0500, Rahul Singh wrote:
> > Ted,
> >
> > I think i know where you are coming from, but let's say I have this
> > representing my properties in my model, what changes would you make
> > to make this work? I think I may be having a senile moment, but i'd
> > greatly appreciate your help.
> >
> > Rahul
> >
> > "
> > protected DateTime _lastTimerStart;
> > protected DateTime _lastTimerStop;
> >
> > public DateTime LastTimerStart
> > {
> > get {return _lastTimerStart;}
> > set {_lastTimerStart = value;}
> > }
> >
> > public DateTime LastTimerStop
> > {
> > get {return _lastTimerStop;}
> > set {_lastTimerStop = value;}
> > }"
> >
> >
> > On Thu, 30 Dec 2004 07:21:02 -0500, Ted Husted <hu...@apache.org>
> > wrote:
> >
> >> On Wed, 29 Dec 2004 17:17:49 -0500, Rahul Singh wrote:
> >>
> >>> "The statement has been terminated. Arithmetic overflow error
> >>> converting expression to data type datetime. "
> >>>
> >>> How do you guys deal with DateTime values as your object
> >>> properties? I'm getting this error when I try to insert the
> >>> object.
> >>>
> >>> Rahul
> >>>
> >> At the moment, I have the model object convert the value back and
> >> forth between a string representation and a binary
> >> representation. The model object has a separate property for the
> >> string representation that do the conversion and pass the binary
> >> to the actual Date property. (So there is no private string
> >> field, just the binary.) The data access methods use the binary
> >> property. The controls use the string property.  The string
> >> methods also watch for the magic null strings, and return blanks
> >> to the controls.
> >>
> >> Next, I'm going to refactor for the Spring Framework, which I
> >> believe has a lot of conversion utilities built in. Spring is
> >> widely used by the Java community, and I expect we'll find the
> >> same on the .NET side soon.
> >>
> >> [http://www.springframework.net/]
> >>
> >> -Ted.
> 
>

Re: issues with datetime as model properties.

Posted by Ted Husted <hu...@apache.org>.
Actually, I've never seen an arithmetic overflow error before. 

Is it possible that your timer values are going past DateTime.MaxValue ?

-Ted.

On Thu, 30 Dec 2004 17:37:52 -0500, Rahul Singh wrote:
>�Ted,
>
>�I think i know where you are coming from, but let's say I have this
>�representing my properties in my model, what changes would you make
>�to make this work? I think I may be having a senile moment, but i'd
>�greatly appreciate your help.
>
>�Rahul
>
>�"
>�protected DateTime _lastTimerStart;
>�protected DateTime _lastTimerStop;
>
>�public DateTime LastTimerStart
>�{
>�get {return _lastTimerStart;}
>�set {_lastTimerStart = value;}
>�}
>
>�public DateTime LastTimerStop
>�{
>�get {return _lastTimerStop;}
>�set {_lastTimerStop = value;}
>�}"
>
>
>�On Thu, 30 Dec 2004 07:21:02 -0500, Ted Husted <hu...@apache.org>
>�wrote:
>
>>�On Wed, 29 Dec 2004 17:17:49 -0500, Rahul Singh wrote:
>>
>>>�"The statement has been terminated. Arithmetic overflow error
>>>�converting expression to data type datetime. "
>>>
>>>�How do you guys deal with DateTime values as your object
>>>�properties? I'm getting this error when I try to insert the
>>>�object.
>>>
>>>�Rahul
>>>
>>�At the moment, I have the model object convert the value back and
>>�forth between a string representation and a binary
>>�representation. The model object has a separate property for the
>>�string representation that do the conversion and pass the binary
>>�to the actual Date property. (So there is no private string
>>�field, just the binary.) The data access methods use the binary
>>�property. The controls use the string property. �The string
>>�methods also watch for the magic null strings, and return blanks
>>�to the controls.
>>
>>�Next, I'm going to refactor for the Spring Framework, which I
>>�believe has a lot of conversion utilities built in. Spring is
>>�widely used by the Java community, and I expect we'll find the
>>�same on the .NET side soon.
>>
>>�[http://www.springframework.net/]
>>
>>�-Ted.




Re: issues with datetime as model properties.

Posted by Rahul Singh <an...@gmail.com>.
Ted,

I think i know where you are coming from, but let's say I have this
representing my properties in my model, what changes would you make to
make this work? I think I may be having a senile moment, but i'd
greatly appreciate your help.

Rahul 

"
		protected DateTime _lastTimerStart;
		protected DateTime _lastTimerStop;

		public DateTime LastTimerStart
		{
			get {return _lastTimerStart;}
			set {_lastTimerStart = value;}
		}

		public DateTime LastTimerStop
		{
			get {return _lastTimerStop;}
			set {_lastTimerStop = value;}
		}"



On Thu, 30 Dec 2004 07:21:02 -0500, Ted Husted <hu...@apache.org> wrote:
> On Wed, 29 Dec 2004 17:17:49 -0500, Rahul Singh wrote:
> > "The statement has been terminated. Arithmetic overflow error
> > converting expression to data type datetime. "
> >
> > How do you guys deal with DateTime values as your object
> > properties? I'm getting this error when I try to insert the object.
> >
> > Rahul
> 
> At the moment, I have the model object convert the value back and forth between a string representation and a binary representation. The model object has a separate property for the string representation that do the conversion and pass the binary to the actual Date property. (So there is no private string field, just the binary.) The data access methods use the binary property. The controls use the string property.  The string methods also watch for the magic null strings, and return blanks to the controls.
> 
> Next, I'm going to refactor for the Spring Framework, which I believe has a lot of conversion utilities built in. Spring is widely used by the Java community, and I expect we'll find the same on the .NET side soon.
> 
> [http://www.springframework.net/]
> 
> -Ted.
> 
>

Re: issues with datetime as model properties.

Posted by Ted Husted <hu...@apache.org>.
On Wed, 29 Dec 2004 17:17:49 -0500, Rahul Singh wrote:
>�"The statement has been terminated. Arithmetic overflow error
>�converting expression to data type datetime. "
>
>�How do you guys deal with DateTime values as your object
>�properties? I'm getting this error when I try to insert the object.
>
>�Rahul

At the moment, I have the model object convert the value back and forth between a string representation and a binary representation. The model object has a separate property for the string representation that do the conversion and pass the binary to the actual Date property. (So there is no private string field, just the binary.) The data access methods use the binary property. The controls use the string property.  The string methods also watch for the magic null strings, and return blanks to the controls.

Next, I'm going to refactor for the Spring Framework, which I believe has a lot of conversion utilities built in. Spring is widely used by the Java community, and I expect we'll find the same on the .NET side soon. 

[http://www.springframework.net/]

-Ted.