Getting date string in correct format

Posts   
 
    
Ian avatar
Ian
User
Posts: 511
Joined: 01-Apr-2005
# Posted on: 16-Jan-2006 18:28:56   

Hi there,

When I use LLBLGen to output the SQL for comparing a date column and a DateTime object's value, it puts the format of the DateTime's value in such a way that different databases can make sense of it. Even when one database would accept this.. '23/12/2005' where as the other would throw an exception because it wanted this.. '12/23/2005'.

So the question is, if I am generating raw SQL without LLBLGen, how can I get a DateTime's value formatted in the same way that LLBLGen does?

Is it even LLBLGen doing it or is it delegating to the SQLClient objects of .net?

Cheers, I

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 17-Jan-2006 07:07:34   

If you are using a SQLParameter of a "SqlDbType.DateTime" type you won't face any problem saving your DateTime variable into a SQL datetime field

Ian avatar
Ian
User
Posts: 511
Joined: 01-Apr-2005
# Posted on: 17-Jan-2006 14:34:45   

Thanks.

I suppose I should have been using SqlParameters anyway to avoid injection attacks.