Puiu Posted April 13, 2007 Posted April 13, 2007 Hello! I'm 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) i'm all years (and eyes :) ) Thank you Quote
Administrators PlausiblyDamp Posted April 14, 2007 Administrators Posted April 14, 2007 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. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.