LLBLGen and Dates

Posts   
 
    
wayne avatar
wayne
User
Posts: 611
Joined: 07-Apr-2004
# Posted on: 10-Sep-2004 12:28:56   

Hi Otis

I used to profiler to see how LLBLGen handles the date formats for SQL.

 @DateOfBirth = 'Sep 10 2004 12:24:50:110PM'

Now my question. Is this a hardcoded dateformat in the Libs of LLBLGen or does it change depending on the regional and sql settings?

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39588
Joined: 17-Aug-2003
# Posted on: 10-Sep-2004 12:52:48   

I do nothing with date values, I just pass a System.DateTime to the parameter. The Sql profiler shows you the lowlevel execution of the query, which is not necessarily how LLBLGen Pro executes the query, but how ADO.NET executes the query.

The date value's format is coming from SqlClient, not from me.

Frans Bouma | Lead developer LLBLGen Pro
wayne avatar
wayne
User
Posts: 611
Joined: 07-Apr-2004
# Posted on: 10-Sep-2004 13:00:54   

Thanks.simple_smile

takb
User
Posts: 150
Joined: 12-Mar-2004
# Posted on: 05-Oct-2004 08:52:49   

wayne wrote:

Hi Otis

I used to profiler to see how LLBLGen handles the date formats for SQL.

 @DateOfBirth = 'Sep 10 2004 12:24:50:110PM'

Now my question. Is this a hardcoded dateformat in the Libs of LLBLGen or does it change depending on the regional and sql settings?

Note that the regional setting DOES effect date handling. We had a situation where our web and app servers were inadvertently built using the default US English regional settings (MM/DD/YYYY) but our Database server had Australian English (and so DD/MM/YYYY). Our queries failed because the application server was formatting date strings in US format and passing that to the DB which was attempting to interpret it in Australian format.

The fact that the SQLServer provider is passing dates as strings seems a little strange and dangerous to me but I haven't had time to look into this yet. I would have thought that dates would be passed as a DateTime datatype.

wayne avatar
wayne
User
Posts: 611
Joined: 07-Apr-2004
# Posted on: 05-Oct-2004 09:05:00   

This is exactly the propblem i had. My Web Server had a different dateformat (DD/MM/YYYY) from my Database server (MM/DD/YYYY) and was receiving the date and month in the wrong order! frowning Luckily i discovered it on the 09/09/2004 - That day saved my butt. simple_smile

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39588
Joined: 17-Aug-2003
# Posted on: 05-Oct-2004 09:53:40   

The date format you see in the profiler is NOT the exact value send to the server. That value is the result of the datetime tick count conversion to a string.

All DateTime values are passed as DateTime to the database, no conversion whatsoever is performed so date format issues shouldn't take place.

Frans Bouma | Lead developer LLBLGen Pro
wayne avatar
wayne
User
Posts: 611
Joined: 07-Apr-2004
# Posted on: 05-Oct-2004 10:37:33   

Otis wrote:

The date format you see in the profiler is NOT the exact value send to the server. That value is the result of the datetime tick count conversion to a string.

All DateTime values are passed as DateTime to the database, no conversion whatsoever is performed so date format issues shouldn't take place.

hmmm....confused Confusing - Why did my months and days get swapped around then? - That is the reason why i looked at the sql being passed in the first place?

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39588
Joined: 17-Aug-2003
# Posted on: 05-Oct-2004 10:57:44   

aha simple_smile But how did you create your datetime object? perhaps you read the date/time in the wrong order? (from the form data)

Frans Bouma | Lead developer LLBLGen Pro
hferland
User
Posts: 13
Joined: 02-Oct-2007
# Posted on: 20-Oct-2008 17:51:35   

I got a similar problem where sqlserver raise the following error: "Msg 8114, Level 16, State 5, Line 0

Erreur de conversion du type de données varchar en datetime. "

If ADO.NET did not send the datetime as a string, there would not be an error regarding convertion from varchar to datetime - I think- !

Is there a way to fix the datetime format ado.net send to sqlserver? Is there any other cause to that problem?

Thanks,

Hugues

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39588
Joined: 17-Aug-2003
# Posted on: 20-Oct-2008 18:34:43   

please do not open an existing thread and please provide more information. See: http://www.llblgen.com/tinyforum/Messages.aspx?ThreadID=7722

Frans Bouma | Lead developer LLBLGen Pro