Datetime problems

Puiu

Well-known member
Joined
Oct 6, 2004
Messages
90
Hello!

Im having a problem with datetime and smalldatetime parameters. I need to insert a date in a smalldatetime field. The problem is that the date comes from the application in different formats depending on how the computer was set.

In this particular case I need to insert a date with hour and minute (13/04/2007 17:45) but on some computers the string returned is something like 13/04/2007 05:45 PM (so i get the error that says it could not convert the string to datetime). I need to insert the minutes like 17:45 so that when the user looks back to know that the action took place in the afternoon and not in the morning.

I think the general question would be: how to receive a valid parameter datetime or smalldatetime no matter the settings on the users computer?

If you have sugestions for resolving this using either .net code or sql (transact-sql) im all years (and eyes :) )

Thank you
 
Could you give a little more detail about how you are generating the SQL Insert command and where the information is coming from?

If you are just concatenating strings then you will get potential issues if the SQL / Application have differernt regional settings and date time formats.

If you could use either a stored procedure or a parameterised query then this issue would probably go away.
 
Back
Top