Click here to Skip to main content
15,886,026 members
Everything / DateTime

DateTime

DateTime

Great Reads

by Christoph Buenger
Describes PHP application development with the free Scavix Web Development Framework (Scavix-WDF).
by Graham Wilson
An exercise to measure the drift in the time-of-day clock on a Windows PC using the periodic timer
by #realJSOP
Find the date of a specified federal holiday for a given year.
by OriginalGriff
Strangely, the .NET DateTime does not provide a Week Number. This extension rectifies this.

Latest Articles

by
An extension library to simplify dealing with .NET's DateTime, DateOnly, TimeOnly and TimeSpan objects, also includes support for the ISO 8601 EDTF profile.
by DiponRoy
Split date time ranges into days or possibly other ranges using CTE in SQL Server
by Bohdan Stupak
Explanation of how DateTime.TryParse behaves with ISO-8601 format
by stc.reseller
Helpful tips in labeling Office files or how to make Office file changes statistically visible, in one single step

All Articles

Sort by Score

DateTime 

31 Oct 2014 by Christoph Buenger
Describes PHP application development with the free Scavix Web Development Framework (Scavix-WDF).
14 Jan 2017 by Graham Wilson
An exercise to measure the drift in the time-of-day clock on a Windows PC using the periodic timer
13 Dec 2011 by OriginalGriff
When you use a DateTimePicker, and set a format so that it only lets the user enter limited info, such as the Date in one, and the Time in another, the resulting values include the current system date/time for the entries the user cannot change. As a result the only safe way to combine the two...
29 Nov 2011 by Savalia Manoj M
You Can try it in MS-SQL Like Declare @Month BigintSet @Month =11Declare @date date;Set @date='2011-11-01'while DATEPART(Month,@date)=@MonthBegin --Select DATEPART(DAY,@date); --Select DATEPART( WEEKDAY, @DATE ) DECLARE @Name VARCHAR(20) SELECT @Name = CASE (...
11 Oct 2010 by m@dhu
Convert.ToDateTime(txtDate.Text).ToString("yyyy-MM-dd")
1 Feb 2017 by #realJSOP
Find the date of a specified federal holiday for a given year.
10 Mar 2011 by Sergey Alexandrovich Kryukov
Here is the answer with the code sample: http://msdn.microsoft.com/en-us/library/5hh873ya.aspx[^].For more flexible option, see this: the class System.Globalization.DateTimeFormatInfo and the sample code provided:...
14 Jul 2011 by OriginalGriff
Strangely, the .NET DateTime does not provide a Week Number. This extension rectifies this.
11 Jun 2012 by Maciej Los
Have a look at this: DateTime.TryParse[^] method and use it.DateTime.TryParse Method (String, IFormatProvider, DateTimeStyles, DateTime%)The most important is:Specific valid formats for date and time elements, as well as the names and symbols used in dates and times, are defined by the...
20 Aug 2015 by OriginalGriff
String - I get a Format Exception, because "YYYY" is not a known format code: it should be: String strDate = "24/01/2013 00:00:00"; DateTime date = DateTime.ParseExact(strDate, "dd/MM/yyyy HH:mm:ss", CultureInfo.InvariantCulture); ...
5 Feb 2020 by F-ES Sitecore
dt.ToString("ddMMYYYY") Custom date and time format strings | Microsoft Docs[^]
23 Apr 2020 by Maciej Los
string query = "SELECT * FROM [TRANSACTION] WHERE ([DT1] BETWEEN #" + fromdate + "# AND #" + todate + "#) OR ([DT2] BETWEEN #" + fromdate + "# AND #" + todate + "#)"; Such of query is SqlInjection[^] vulnerable! Rather than it, use...
15 Sep 2010 by William Winner
Well, to be a bit more helpful, all you're looking for is:date.ToString("MM/dd/yyyy")//ordateplus3.ToString("MM/dd/yyyy")Really, though, this is a pretty simple thing to google and I would suggest starting there in the future.
15 Sep 2010 by William Winner
In response to your new question, your problem is going to be related to the fact that you've switched the date and the month.Your culture settings probably have the DateTime specified as MM/dd/yyyy, which means that when it sees 15/9/2010, it says there is not month with the number of...
10 Mar 2011 by William Winner
if the formats here: Standard Date and Time Format Strings[^] aren't giving you the results you expect, then you may need to check your culture settings.
9 May 2011 by Toniyo Jackson
Write the below code in dtpDeliveryDate ValueChanged Event.private void dtpDeliveryDate_ValueChanged(object sender, EventArgs e){ dtpDate.Value = dtpDeliveryDate.Value.AddMonths(1);}
4 Nov 2011 by Wonde Tadesse
This problem is similar to Ethiopian calender. In Ethiopian calender[^], a year contains 13 months, the first 12 months have 30 days,the last month has 5 or 6 days depends on the leap year. New year starts September 11 or 12 based on the leap year so and so forth. So the only solution to work...
10 Nov 2011 by #realJSOP
How about this?public static class ExtendDateTime{ public int CountWeekDays(this DateTime thisdate, DateTime thatDate) { int days = Math.Abs((thisDate - thatDate).Days) + 1; return = ((days/7) * 5) + (days % 7); }}Usage would be like this:DateTime...
1 Feb 2012 by Sergey Alexandrovich Kryukov
Well, it means the string cannot be parsed as System.DateTime. You need to specify expected format. The right approach is...
6 Dec 2012 by xibao
Code to produce holidays for NYC Stock Exchange.
24 Dec 2012 by OriginalGriff
It';s not odd at all - it is exactly what you asked for: minutes/day/year.If you want the month on the other hand:user.StartDate.ToString("MM/dd/yyyy");Would probably be what you wanted.
22 Oct 2013 by Sergey Alexandrovich Kryukov
This is a structure, a value type and hence is not nullable. You can make a member or a variable of System.DateType nullable if you use the type System.DateType? instead:System.DateType? myTime = null;//...if (myTime == null) //...Please see:...
8 May 2014 by OriginalGriff
It makes sense to me! :laugh:This explains it: http://msdn.microsoft.com/en-us/library/ms178091.aspx[^]:CONVERTDeterministic unless one of these conditions exists:Source type is sql_variant.Target type is sql_variant and its source type is nondeterministic.Source or target type is...
10 May 2015 by Kornfeld Eliyahu Peter
The problem is that the format string 'MM-dd-yyyy' does not fir to the value '2015.05.05' and for that ParseExact will throw an exception of invalid value... You may try TryParseExact, but the only thin you will get, that no exception will be thrown, but a boolean value will be returned - but...
10 Jun 2015 by Dave Kreskowiak
Why are you using DateTime.Now to do this??There is the System.Diagnostics.Stopwatch class that's a lot better for timing something like this.
20 Aug 2015 by Richard Deeming
The DateTime type[^] does not have a format. The value is stored as the number of "ticks" (100 nanoseconds) since midnight, January 1, 0001 A.D. (C.E.) in the Gregorian calendar.What you are seeing is the debugger's representation of that value, which converts the DateTime to a string using...
27 May 2017 by OriginalGriff
When I try it: DateTime serverDate = DateTime.Now; string currentDateString = string.Format("{0}", serverDate.ToString("yyyyMMddHHmmssffffff")); Console.WriteLine(currentDateString); I get what I expect: 20170527091049145901 yyyyMMddHHmmssffffff So I'd...
1 Feb 2019 by F-ES Sitecore
Enumerable.Range(1, 31).Select(day => DateTime.Now.AddDays(day)).ToList();
24 Mar 2019 by CHill60
1. Using SEC_TO_TIME, TIME_TO_SEC seems like overkill. Why not just use TIMESTAMPDIFF[^] 2. You have a poor db design - there is no need to repeat the workers forename and surname in the leave table - you have that information on the workers table and you have a link to that table in...
28 Oct 2019 by stc.reseller
Helpful tips in labeling Office files or how to make Office file changes statistically visible, in one single step
N 12 Apr 2024 by OriginalGriff
Without your data and some idea what the error message is (and the actual data that generates it) we can't help you - and you have to remember that we can't see your screen, access your HDD, or read your mind - we only get exactly what you type...
21 Jun 2010 by TheyCallMeMrJames
This will never return true.The code is asking if it's ever between tonight at 11:30 pm and this morning at 2 am. If I'm understanding the logic correctly, I think you need an OR instead of an AND.Cheers.
15 Sep 2010 by Chrysogon
You can specify the format you want the date and time back in:String s = DateTime.Now.ToString("d-M-yyyy hhmmss")Might help.
17 Jan 2011 by KevinAG
Your statement of, "I wanted to validate text inputed by a user as they were typing to tell them if it was a valid date." seems to be a bit misleading. I was under the impression that your code would start off returning true until I entered a non-number character, invalid separator, or invalid...
27 Jan 2011 by shakil0304003
You can see this linksClickClickClick
2 Oct 2011 by Gary Bilkus
How to get Silverlight 4 to display dates by default using the regional settings in the Control Panel.
1 Dec 2011 by CPallini
What's wrong with:Dim dt As Date = Now.AddDays(-90)?
4 Dec 2011 by Anuj Banka
try to set '12/14/2011' If this will worked fine.Then you have to change the format of the date before setting this .Your picker taking this format DD/MM/YYYY you have to change the date in to this format
4 Dec 2011 by S.P.Tiwari
hi.chane you date picker formate into MM/DD/YYYY format.you will not get that taype of exception
13 Dec 2011 by Abhinav S
Tryvar date = new DateTime(x,y,z); // x,y,z are year.month and date respectivelvar time = TimeSpan.Parse(time); var combo = date + time;
4 Jan 2012 by Andrew Rissing
I would just start eliminating variables to what could be causing the problem:1) Supply constant date times for the SQL parameters (SDate and EDate) (i.e. DateTime.Now.ToString("dd-MM-yyyy")) rather than the text boxes. If that doesn't fix it, continue.2) Make sure the type of the...
7 Feb 2012 by Abhinav S
[Transaction Date] >= #" & fnGetClientDate(dtpFromDate.Text) Make sure the type of the two fields is DateTime.
4 May 2012 by OriginalGriff
Try:DateTime SixMonthsOn = DateTime.Now.AddMonths(6);
31 May 2012 by Manas Bhardwaj
You can use triggers. Look at the article below and the MSDn documentation.http://benreichelt.net/blog/2005/12/13/making-a-trigger-fire-on-column-change/[^]http://msdn.microsoft.com/en-us/library/ms186329.aspx[^]
1 Jun 2012 by abhinavvijay
write below querySet dateformat dmyselect * from Inscription where datePreInscription >convert(datetime,'31-5-2012')
1 Jun 2012 by Maciej Los
Try this:DECLARE @sDate VARCHAR(10)SET @sDate = '2012-05-31'SELECT * FROM InscriptionWHERE datePreInscription = @sDate
12 Jul 2012 by Prasad_Kulkarni
Refer:Easy String to DateTime, DateTime to String and Formatting[^]Formatting a DateTime for display - format string description[^]Also referCodeProject Answers[^]
2 Aug 2012 by BobJanova
There's two possible situations with the range: either it goes over a day boundary (e.g. 1800-0600) or it doesn't (e.g. 0600-1800). One of them needs a simple range check and one needs the check given by Mehdi, or a check with the next day. You check which you have by comparing the...
16 Oct 2012 by MT_
A simple DateTime.Compare(date1,date2) should work.http://msdn.microsoft.com/en-us/library/system.datetime.compare.aspx[^]
5 Jan 2013 by Reza Alipour Fard
HiI test you code it execute without error.Please attend to bellow point:1)This code is OK.dataGridView1.CurrentRow.Cells[YourColumnNumber].Value = DateTime.Now;2)The first column number is zero, therefore if you want add date to third column you must use from 2 az...
3 Mar 2013 by gvprabu
Hi ,Try like this...DECLARE @Date VARCHAR(10)='20120404', @FirstDate VARCHAR(10), @FirstDay INT, @LastDay INTSELECT @FirstDate=SUBSTRING(@Date,1,6)+'01'SELECT @FirstDay=1, @LastDay=DATEDIFF(DAY,@FirstDate,DATEADD(MONTH,1,CONVERT(DATETIME,@FirstDate,103)))SELECT...
6 Mar 2013 by Amol_B
you can even do it in one lineSELECT DATEADD(month, DATEDIFF(month, 0, GETDATE()), 0)SELECT DATEADD(DAY, -(DAY(DATEADD(MONTH, 1, GETDATE()))),DATEADD(MONTH, 1, GETDATE()))
13 May 2013 by gvprabu
Hi,Check the following CodeSELECT GETDATE()GO-- SQL Server 2000/2005SELECT CONVERT(VARCHAR(8),GETDATE(),108) AS HourMinuteSecond,CONVERT(VARCHAR(10),GETDATE(),101) AS DateOnly;GO-- SQL Server 2008 OnwardsSELECT CONVERT(TIME,GETDATE()) AS HourMinuteSeconds;SELECT...
3 Aug 2013 by André Kraak
You have duplicates because the orderPeriod field is in the SELECT statement.Remove this field from both the SELECT and GROUP BY and you should get a total for each product without duplicates.SELECT DISTINCT productName, SUM(quantity) AS Expr1 FROM WP_analytic WHERE (orderPeriod >=...
25 Sep 2013 by NeonMika
Hey there community,I have one question why my code is working. :PYeah, sounds strange, but I'm just curious...When I'm starting my application in English I'm setting my current culture info:CultureInfo cultureInfo;cultureInfo = new...
22 Oct 2013 by Thanks7872
See this: Custom Date and Time Format Strings [msdn][^]Regards..
6 Jan 2014 by Karthik_Mahalingam
try this.string datestr = "01.08.2014"; string format = "MM.dd.yyyy"; DateTime dt = DateTime.ParseExact(datestr, format, System.Globalization.CultureInfo.InvariantCulture);
1 Feb 2014 by OriginalGriff
No, it isn't.DATETIME and DATE fields ion SQL do not have a "format" any more than they do for DateTime values in C# - they are stored as a number of milliseconds since an arbitrary point in the past. Formatting is only ever applied when the date is converted to a string to display to the user...
8 May 2014 by OriginalGriff
First off, don't use the registry.The registry in Vista and above need admin access to modify, so every time you call SetNewDate you app will require UAE access, and this can only get more rigid in future versions.Instead, create a licence file and store it somewhere more accessible: Where...
11 Jun 2014 by DamithSL
you can get only the date from ASP.NET Calendar control. you need to find jQuery or other extended Calendar control which support both Date and Time, Check below Article for how to use jQuery DateTime picker and fetch selected datetime from code behind.DateTimePicker control for ASP.Net...
19 Jun 2014 by DamithSL
I'm trying to recreate your problem.DateTime dt1 =DateTime.ParseExact("19-06-2014 00:01:13", "dd-MM-yyyy HH:mm:ss",null);DateTime dt2 =DateTime.ParseExact("18-06-2014 23:58:13", "dd-MM-yyyy HH:mm:ss",null);with above two DateTime objects,var minutes = (dt1-dt2).TotalMinutes; // result...
23 Nov 2014 by DamithSL
replace DateTime da = new DateTime();with DateTime da = DateTime.Now;and also you need to use "@date" when setting parameter value like below comm.Parameters.AddWithValue("@date", da);
14 Dec 2014 by CPallini
Something like: string enter = "15/12/2014 21:00"; string leave = "16/12/2014 11:00"; DateTime dtEnter = DateTime.Parse(enter); DateTime dtLeave = DateTime.Parse(leave); TimeSpan tsWorkHours = dtLeave - dtEnter; Console.WriteLine("Work hours {0}", tsWorkHours.Hours);
16 Jan 2015 by Richard Deeming
Custom Date and Time Format Strings[^]:string formattedDate = DateTime.UtcNow.ToString("yyyy-MM-dd HH:mm:ss");// Example output: 2015-01-16 16:26:32
16 Jan 2015 by Sergey Alexandrovich Kryukov
In addition to Solution 1:Please see all related methods:http://msdn.microsoft.com/en-us/library/system.datetime.tostring%28v=vs.110%29.aspx[^].What you need is formatting. is not "conversion". Note that parameters allows you to format depending on culture...
21 Mar 2015 by Abhinav S
Its an array. So use two tables.In the first table mark the id of the datetime values.In the second table, repeat the id and store the array items as rows one by one.Table 1ColA ColB DateId.. .. 1.. .. 2...Table 2DateId DateValue1 Date11 Date22 ...
13 Apr 2015 by OriginalGriff
Don't.Never store DateTime values in a DB as a string: parse them at point of input (or as close as you can get) because only then can you tell what format the user has input them in, and that they are correct. It's far too late by the time they get to the database as they have lost all user...
31 May 2015 by Maciej Los
It's quite simple:--temp table - because it's just an example, you need to refer to existing tableDECLARE @tblEmployee TABLE (EmployeeNo VARCHAR(10), EmpName VARCHAR(255))INSERT INTO @tblEmployee (EmployeeNo, EmpName)VALUES('00002', 'Tiamsic, Juan'),('00001', 'Dela Cruz,...
12 Dec 2015 by ridoy
You can use Calender.before(), Calender.after() and Calender.equals() like this way:Calendar cal1 = Calendar.getInstance();Calendar cal2 = Calendar.getInstance();cal1.setTime(date1);cal2.setTime(date2);if(cal1.after(cal2)){ System.out.println("Date1 is after...
15 Jan 2016 by Richard Deeming
Fixing the SQL Injection[^] vulnerability in your code will most likely solve the error message as well:Private Sub viewrptrs_Click(sender As System.Object, e As System.EventArgs) Handles viewrptrs.Click Using con As New SqlConnection("Data Source=ASHUTOSH-PC\SQLEXPRESS;Initial...
9 Nov 2016 by Kornfeld Eliyahu Peter
It has something to do with your local date settings...Convert.ToDateTime("") is equivalent to DateTime.Parse("", CultureInfo.CurrentCulture), so it is obvious that the YYYY-MM-DD does not fit your local... It seams to be YYYY-DD-MM, as it try to interpret 26 as month an fails...Use...
3 Jan 2017 by Wendelius
There are quite a few problems to fix. Consider the following alternativestring sql;DataSet dsa = new DataSet();DataTable dt = new DataTable();dsa.Tables.Add(dt);using (OleDbConnection connection = new OleDbConnection(connectionString)) { sql = @"SELECT * FROM [Sales Record]...
22 May 2017 by Maciej Los
Quote: "Wed May 03 2017 05:04:00 GMT+0530 (India Standard Time)" from this string only want "May 03 2017 05:04:00" this part. No, you don't. You need almost entire text to be able to convert that string into date, at least: Wed May 03 2017 05:04:00+0530 I answered your previous question here:...
13 Jul 2017 by Andy Lanng
Well I'd suggest stripping the time out and compare the two dates that way: public static int HowManyDaysFromToday(DateTime appointment) { var today = DateTime.Today; //like DateTime.Now but with no time aspect var appDay = appointment.Date; return appDay.Subtract(today).TotalDays; } ...
14 Jul 2017 by Pete O'Hanlon
If I were doing something like this, I would do it like this:public static DateTime(int days) { return new DateTime.Now.Subtract(TimeSpan.FromDays(days)); }
29 Aug 2017 by OriginalGriff
You can't convert a Timespan to a DateTime: that doesn't work because it's not a logical action. Think about it: If I ask you to meet me at "plus 6 hours 30 minutes" what does that mean? Nothing - unless it's understood that there is a starting point for it to be relative to. In terms of normal...
16 Oct 2018 by OriginalGriff
Assuming that the integer value is "days since 1/1/1900", then you have to convert that to a date. So each leap year has 366 days, and each non-leap year has 365. Leap years are all those years divisible by 4 in the range 1900 to 2099, so I'd create an array of "year counts" 0, 365, 365+365,...
26 Dec 2018 by OriginalGriff
You can't: DateTime values don't have a format, they are stored as a number of ticks since a specific moment in time. They only acquire a format of any kind when they are converted to strings for presentation to the user in some way - and then the format would normally depend on the users own...
16 Jan 2019 by Maciej Los
Well, there's no "common list of holidays". It depends on country (national, public holidays) and religion. See: National day - Wikipedia[^]. The easiest way to detect if current day is a holiday, is to define a list of them. Note that some holidays are dependent of Easter... Sub Main Dim...
25 Feb 2019 by OriginalGriff
Have you tried SELECT FORMAT (GETDATE(), 'MM/dd/yyyy ') AS Date You do realise that formatting only applies to dates in strings - dates which are prepared for presentation to the user in some form. No formatting you apply to a DATE, DATETIME or DATETIME2 column will be retained as dates are...
25 Feb 2019 by Maciej Los
Please, read my comment first, then refer this article: Dealing with custom date formats in T-SQL - SQLServerCentral[^] For further details, please see: CAST and CONVERT (Transact-SQL) - SQL Server | Microsoft Docs[^]
22 May 2019 by lmoelleb
yyyy-MM-dd HH:mm:ss is a format "for human consumption". It is not a good format for a database, nor a good format for a program. And it is certainly not a good format for a program to communicate with a database. It isn't even a good format for Excel, so most likely this is not what is stored...
28 May 2020 by phil.o
Why ignoring the success for the last step? You could try either newTask.Priority = ReadPriority(out success); return newTask; // ignoring success status or newTask.Priority = ReadPriority(out success); if (!success) return null; return...
19 Oct 2021 by Luc Pattyn
No no. That is not OK. You can't accurately measure time intervals below one microsecond like that; first of all the system clock doesn't have that fine a resolution, then getting DateTime.Now has a cost involved, and finally there is no...
16 Jan 2022 by Luc Pattyn
Hi, your ComboBox3.SelectedIndex = i is not doing anything useful. Your Dim parsedate As DateTime = ComboBox2.SelectedItem.ToString will give the same result on each iteration of your loop, and all items in ComboBox3 will end up showing the...
12 Jul 2022 by 0x01AA
See also my comment to the question. If I understand your request correctly, something like below should do the job: DateTime DateStart = new DateTime(dateTimePicker1.Value.Year, dateTimePicker1.Value.Month, dateTimePicker1.Value.Day, 12, 0, 0);
25 Aug 2022 by Richard MacCutchan
Well, I just tried that and the output is: ['2002', '09', '18'] 2002-09-18 00:00:00 ambiguous Which obviously shows that the date is not in the format that you assume. So if we look back at the line: dt.strftime('%d/%m/%Y') we can see...
10 Mar 2024 by Pete O'Hanlon
I'm making an assumption here that you are talking about converting the two SYSTEMTIME structures in the DYNAMIC_TIME_ZONE_INFORMATION object. To accomplish this, I believe that you are going to start by converting the SYSTEMTIME structure to a...
N 14 Apr 2024 by M Imran Ansari
In addition to Solution-1, it's advisable to explore further on your own. It's likely that the `lastUpdate` column might contain some null values, triggering exceptions during calculations. You can also try to modify query handle this scenario by...
18 Mar 2010 by Richard MacCutchan
Member 2068169 wrote:the date field throws errorHow is anyone expected to guess what the error is?
31 Mar 2010 by Nuri Ismail
You could use SetFileTime[^] function or _utime[^] function family in order to change the last modified time of a file. :)
17 Apr 2010 by Sandeep Mewara
It looks like you want to ask this question to an author related to his/her article. I would suggest you to please use the forum present at the end of the article in order to reach author and get quick response. Rarely you will find authors reading this forum. Please post the same at the...
21 Jun 2010 by Richard MacCutchan
I suspect the second half of the expression was supposed to increment the day so the expression would test to see if the time is between 23:30 tonight and 02:00 tomorrow morning. However the programmer either missed that totally or couldn't figure out what to do at the end of the month or year....
21 Jun 2010 by William Winner
no...it will always return false.That statement is saying, "Is the current time after 11:30pm today and before 2am today."Written a different way, it saysreturn (DateTime.Now.Hour = 23 && DateTime.Minute >= 30) && (DateTime.Now.Hour
21 Jun 2010 by Alan N
I think maybe it can be true as DateTime.Now returns the current clock and that value is constantly changing.Consider what might happen if the clock reads 23h59m59.99s for the first comparison and for the second it has incremented to 00h00m00s. To be truly reliable the method should read...
9 Jul 2010 by helianthus87
Did you pasted exact code fragment? Why there is "dd-MMM-yyyy ...". I don't think tripple M is correct month format.
9 Jul 2010 by /randz
Hi bedathur_ganesh,Have you tried using .Parse instead of .ParseExact? If your date is in the format like the value of string dateTime, then using ParseExact will fail since the format of the dateTime's value is dd-MM-yyyy hh:mm:ss and you want to parse it exactly in dd-MMM-yyyy...
18 Aug 2010 by Nuri Ismail
This works fine for me:static double DiffDays(DateTime dt1, DateTime dt2){ return (dt1 - dt2).TotalDays;}:)
14 Oct 2010 by InActive
How to use the .NET DateTime class in C++ to generate a basic calendar via a console program
22 Nov 2010 by RelicV
you need to convert the edit mode into normal mode by just giving the "editIndex" value as -1.Try this after you update/delete/insert your recordgridview.EditIndex = -1;This should be fine..Regards,Vamsi