problem with inserting date in a datetime field

Hi, I have a problem when I insert a date in a datetime field in a MSSQLServer.

That's my problem:
if the server is in english version, I have to insert date with this code:


instead if the server is in italian version, I have to insert date with this code:


Is there a way to insert a date in standard way, without knowing the server version?
bye and thanks in advance
4/24/2004 3:17:34 PM 29906 articles. 0 followers. Follow

3 Replies

Similar Articles

[PageSpeed] 24

I usually find that yyyy-mm-dd does the trick. But I can't swear it will always work. Actually what am I talking about, you should be using params and this won't be a problem.
4/25/2004 9:36:18 AM

What if you insert the date in datetime format instead of converting it to string? Then maybe, just maybe sql server will recognize the format.
4/27/2004 6:20:06 PM
>> What if you insert the date in datetime format instead of converting it to string? Then maybe, just maybe sql server will recognize the format. 

You're on the road to SQL hell if you do that. What culture is your client, what culture is the database? Use params, there is hardly *ever* a reason not too almost always a problem with an alternative - unless you've written very well thought out DB classes.
4/28/2004 10:15:10 AM

Similar Artilces:

Calendar Control - SQL datetime field
Hi, I have a webform where the staff can request a day off, everything is working perfectly except from the fact that it refuses to save the date into the date field properly, opting to save dates along the lines of '05/15/1900 00:00:00' which as you can imagine is not much use to me. The field in the SQL table is set to 'datetime' and the ASP.NET code used to insert the record into the database is as follows; DBInsert.CommandText = "Insert INTO TBL_Holidays " _ & "(AgentRef, WhenRequested, ActivityDate, TimeTaken, TheNote, Status, TeamRef) Values ...

.NET DateTime and SQL Server DateTime problem
.NET DateTime and SQL Server DateTime problem  I have the following if statement in an SQL stored procedure: IF (@Image = 1 AND @DateTimeUploaded = (SELECT ImageMainDateTime FROM Images WHERE UserID = @UserID))   The value of the @DateTimeUpdated variable was taken from the ImageMainDateTime field when the data was requested by a ASP.NET webpage and is passed back here when that page is submitted so I can compare what the DateTime was when the data was requested with what it is now, in other words I’m doing a concurrency check (I can’t use TimeStamp for many reasons, ...

Problem inserting sql query into database float datatype field using SQL Transaction
I have this problem of inserting my query into database field. My code is as of below. The @AVERAGESCORE parameter is derived from Dim averagescore As Single = (122 * 1 + 159 * 2 + 18 * 3 + 3 * 4 + 0 * 5) / (122 + 159 + 18 + 3 + 0) and the value returned is  (averagescore.toString("0.00")) However, I have error inserting the averagescore variable into a field of datatype float during the transaction. I have no problems when using non transactional sql insert methods. What could be the problem?   Try Dim i As Integer ...

HOW DO I: Insert nulls into SQL dateTime field stored in SQL DB from a web UI textbox
I’m looking for feedback on the Best/Right way to Insert nulls into SQL dateTime field in SQL DB from a web UI textbox.    Option 1:     Presently implemented:  Dim dtFollowUpDate = IIf(dtDateFollowUp.Text = "", System.Data.SqlTypes.SqlDateTime.Null, dtDateFollowUp.Text) Although ithis does what is needed it generates the following inner exception   ParamValue    {System.Data.SqlTypes.SqlDateTime} Object[System.Data.SqlTypes.SqlDateTime] {System.Data.SqlTypes.SqlDateTime}          ...

Problems Inserting a date into a field
I need to convert a date into mm/dd/yyyy before doing an insert into a database.I keep getting an error message with the INSERT statement. Says missing a , or ' or ".Here is my SQL:VALUES ('""CAST(CONVERT(char(8), GETDATE(), 112) As DateTime,'"                sSQL += dr.Item("channel").ToString.Replace("'", "''") & "','" Well, cant you simply convert the date via code from the ToString("mm/dd/yyyy") function and pass it to the stored procedure?Sonu Kapoor [MVP] Feel free to ask me any .NET question | Ajax Data Controls Forum Ok I have not done ...

Inserting Date ONLY from SQL DateTime
with an SQL Database the DateTime data type will insert both date and time, however i have a formview with a textbox for inserting a date. i want to be able to only insert the data so that on other pages where the page must search through the database for relevant dates that it wont have a problem because the field has more values (that being the time). How do i get it to insert ONLY a date. it must be a date and not anything like char(11) as it needs to be validated and searched (unless someone can tell me how to search a database for records between dates thats fields are not dates).I dont...

problem with inserting datetime field
Dear all, I am bit new to dotnet world. currently i am making web application using using C# , Studio 2005).In a web page i am saving date field to sql and on edit populating back to web page.i am fetching the date field from calendar control as Calendarfollowdt.SelectedDate;which i assaign to datetime object that is calenderdt (this code i wrote in Calendarfollowdt_SelectionChanged()). But when i am accessing calenderdt in savebutton. it does not showing correct even through i have define datetime object as public.i am not able to fine out what is a problem. please help ...

sql insert date problem
I have a problem insert date in sql datetime field. I get value from telerik datetime pickre (17.11.2008 0:00:00 ) when i convert in datetime i have error The conversion of a char data type to a datetime data type resulted in an out-of-range datetime value.The statement has been terminated. DateTime date = odg.SelectedDate.Value;///odg is telerik datetime picker String update = "INSERT INTO baseg (od) VALUES ('" + date + "') ";SqlConnection con = new SqlConnection(connectionString);SqlCommand cmd = new SqlCommand(update, con); con.Open(); cmd.ExecuteNon...

Problem inserting integers and date in a sql server 2005 datatable row and selecting it afterwards based on the date
Hi,   I have soma code that inserts 7 parameters in a database ( a date, 6  integers). I also use a self incrementing ID but the date is set as primary key because for each series of 6 numbers of a certain date there may only be 1 entry.  Moreover only 1 entry of 6 integers is possible for 2 days of the week, (tue and fr). I manage to insert a row of data in the database, where the date is set as smalldatetime and displays as follows:  1/05/2007 0:00:00 in the table. I want to retrieve the series of numbers for a certain date that has been entered (without ta...

Problem on insert the current date into SQL
 Hi All,please bear with me if the question is naive, I am new in will like to add the insert the current date when user try to insert new data into database through a web form. when I am trying to run an insert command in an asp page,  INSERT INTO custInfo (ID, QTY, InsertDate) VALUES ('" & ID & "',''" & QTY & DateTime.Now &")I got this error:  Incorrect syntax near '16'. (the date time at this moment is: 15/9/2007 16:11:59) while if I add the single quote on the front and back of & DataTime.No...

inserting the date into SQL Server problem
Im having problems inserting the current date into SQL server from my application. The error that throws is: "The conversion of a char data type to a datetime data type resulted in an out-of-range datetime value. The statement has been terminated. " In my page, im setting the date as follows: Dim strDate as Date strDate = now() Then in my page I call a function called "do_store" This works fin putting my variables into my database until I tried adding the date to the statement. Here is my function. Can anyone see my problem? Public ...

Problem inserting Now() into a datetime field
HiI am trying to insert value retrieved from Now() into a datetime field in my MSDE database, but I am getting the following error, and I have no idea what is going wrong.Arithmetic overflow error converting expression to data type datetime.The statement has been terminated.Here is the code I am using:Dim user As String = MyContext.User.Identity.Name.ToString Dim TimeDate As DateTime = Now() Dim status As String = "Pending" With SqlOrders.InsertParameters .Item("UserName").DefaultValue = user .Item("OrderDate").DefaultValue = Tim...

problem updating datetime field to SQL
HI I have a problem with this sql update: sql = "UPDATE Table1 SET remove=1, removaldate='" & DateTime.Now & "' " & _ " WHERE username='" & Session("username") & "'" comandosql = New SqlCommand(sql, conn) Try comandosql.Connection.Open() comandosql.ExecuteNonQuery() comandosql.Connection.Close() comandosql.Connection.Dispose() ........ The error is: System.Data.SqlClient.SqlException: The conversion...

Select all dates from SQL datetime field
I have a form that's filtering search results and porting to a gridview. The drop down is selecting from the date column of SQL, but i want it the default value to show all dates in the gridview. In a normal string field, you can just use "%", but a datetime field won't take this. What can i use to show all dates? Can you post the SQL you have currently and how the value from the ftont-end is passed to the DB?***********************Dinakar NethiLife is short. Enjoy it.*********************** <asp:SqlDataSource ID="LDSSqlDataSource1" runat="serve...

Web resources about - problem with inserting date in a datetime field -

Inserting Kate
jurvetson posted a photo: the speaking GPS avatar that we came to love.. more prep photos below... You can hear her voice in the video compilation ...

Inserting the Galaxy Note 5’s S Pen backwards can permanently damage the device
One of the features Samsung highlighted when it unveiled the Galaxy Note 5 was the device's new S Pen slot design. The Note 5 features a spring-loaded ...

Inserting Slavery Into The Climate Debate
Chris Hayes compares the fight against fossil fuels to the abolitionist movement. He states plainly that “there is absolutely no conceivable ...

Samsung smart TVs inserting ads into third-party apps
... playback have pissed off a number of consumers. People with smart TVs from Samsung have been complaining that the electronics maker is inserting ...

Samsung: Inserting the S Pen backwards will not break new Galaxy Note 5 units
... according to the company. "Samsung can confirm that the Note 5 internal S Pen mechanism has been changed to avoid the issue caused by inserting ...

Gawker tells Steven Crowder to "stop whining, take your licks, and accept that getting hit in the face ...
"... in the middle of an argument between billionaire-funded know-nothing ideologues and people whose livelihoods and stability are being threatened ...

Gmail's Shortcut for Inserting Hyperlinks
... but that doesn't mean Google shouldn't improve them. Many people complained that Gmail's rich text editor doesn't have a shortcut for inserting ...

Now Samsung SmartTVs are interrupting users' videos by inserting random ads
... room. Now Samsung is dealing with a new headache: Gigaom reports that Samsung SmartTVs are interrupting users' own video content by inserting ...

Samsung SmartTVs are inserting ads into movies - Business Insider
Random Pepsi pop-up ads have been appearing when SmartTV users watch content through the device's third-party apps.

Resources last updated: 1/22/2016 11:08:51 PM