Hi Fabio, I'm aware of that, that's why I just asked for a pointer to
the correct file, not for a solution. I wouldn't have thought this has
changed that much, but obviously I don't know... Anyway, I eventually
found the prob, I'm not sure if this is something that will affect the
2.0 branch too. I changed the following method in DateTimeType.cs
from:
public override void Set(IDbCommand st, object value, int index)
{
IDataParameter parm = st.Parameters[index] as
IDataParameter;
DateTime dateValue = (DateTime) value;
parm.Value =
new DateTime(dateValue.Year, dateValue.Month,
dateValue.Day,
dateValue.Hour, dateValue.Minute, dateValue.Second);
}
to this:
public override void Set(IDbCommand st, object value, int index)
{
IDataParameter parm = st.Parameters[index] as
IDataParameter;
DateTime dateValue = DateTime.Parse(value.ToString());
parm.Value =
new DateTime(dateValue.Year, dateValue.Month,
dateValue.Day,
dateValue.Hour, dateValue.Minute, dateValue.Second);
}
Instead of casting 'value' as a DateTime, I used DateTime.Parse
instead.
Regards, Ben
On Jul 8, 2:15 pm, Fabio Maulo <[email protected]> wrote:
> Ben, NHibernate 1.2.0.4 is 3 year old.
>
> 2009/7/8 Fabio Maulo <[email protected]>
>
>
>
> > Tuna -> NHibernate 1.2.0.4
>
> > 2009/7/8 Tuna Toksoz <[email protected]>
>
> > Can you try this with HQL, so that I better understand the issue?
>
> >> Tuna Toksöz
> >> Eternal sunshine of the open source mind.
>
> >>http://devlicio.us/blogs/tuna_toksoz
> >>http://tunatoksoz.com
> >>http://twitter.com/tehlike
>
> >> On Wed, Jul 8, 2009 at 1:23 PM, benArrayx <[email protected]> wrote:
>
> >>> Hi there, I'm using NHibernate 1.2.0.4 on SQL Server 2005. I am using
> >>> a Criteria query with a clause as follows:
>
> >>> crit.Add(new NHibernate.Expression.LeExpression("PartnershipDate", new
> >>> DateTime(DateTime.Now.AddYears(lengthOfMarriage * -1).Year,
> >>> DateTime.Now.Month, DateTime.Now.Day)));
>
> >>> This generates the following log entry sql (I've replaced the field
> >>> names with * for clarity):
>
> >>> SELECT * FROM WPR_Test.dbo.[MP] this_ WHERE this_.[IsImportTemp] = @p0
> >>> and this_.[PartnershipDate] <= @p1; @p0 = 'False', @p1 = '08/07/2006
> >>> 00:00:00'
>
> >>> However, this query is not generating the expected results. Using sql
> >>> profiler, I checked the actual statement run, which is this:
>
> >>> exec sp_executesql N'SELECT * FROM WPR_Test.dbo.[MP] this_ WHERE this_.
> >>> [IsImportTemp] = @p0 and this_.[PartnershipDate] <= @p1',N'@p0 bit,@p1
> >>> datetime',@p0=0,@p1='2006-07-08 00:00:00:000'
>
> >>> As you can see, the date '2006-07-08 00:00:00:000' from profiler does
> >>> not match the date from the log which is '08/07/2006 00:00:00' as the
> >>> profiler query is saying the 7th August, whereby the log query is
> >>> saying the 8th July.
>
> >>> Obviously this is a simple mis-formatting, I have all the source code
> >>> for the version I'm using, but I can't find where this formatting
> >>> happens to correct it. If anyone could point me at the relevant part
> >>> of the code I'd appreciate it :)
>
> >>> Regards, Ben
>
> > --
> > Fabio Maulo
>
> --
> Fabio Maulo
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"nhusers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nhusers?hl=en
-~----------~----~----~----~------~----~------~--~---