Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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

  • Administrators
Posted

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.

Posting Guidelines FAQ Post Formatting

 

Intellectuals solve problems; geniuses prevent them.

-- Albert Einstein

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...