Click here to Skip to main content
15,891,868 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 vickyqu115
A comprehensive guide on identifying issues with the standard WPF DatePicker, exploring its design and interaction intricacies, and introducing a new implementation using a CustomControl named SmartDate.
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

All Articles

Sort by Title

DateTime 

4 Aug 2013 by Sai Janani
I am using the below code trying to insert data into database. the value for them comes from 3 calendar controls targeted to 3 textboxes. Now when i try to insert the value of textbox into my oracle table, its throwing not a valid month error.The columns type of table is date inside the...
4 Aug 2013 by Basmeh Awad
try using the date format for inserting as "dd-MMM-yyyy"..while targetting to textbox bring the values in the format "dd-MMM-yyyy"like this 04-Aug-2013..if these control were DateTimePicker the you can use this insert queryQry = "Insert into shcemaname.tablename" & _ ...
4 Aug 2013 by Joezer BH
Best practice is that you use parameters if you can (see this how to thread[^]).Using parameters will protect you from SQL Injection[^].Now regarding the DB not accepting the string, all you need to do is convert the string to Datetime in your VB code and then the DB is sure to work with...
28 Aug 2022 by Apoorva 2022
Following is a date validation program. I'm trying to print the date in words. I got the 'str' object is not callable' error at this line --> av=date(day, month, year).strftime('%d %B %Y') But I did convert day, month, & year into integers...
28 Aug 2022 by OriginalGriff
Look at the error message: 'str' object is not callable' error at this line --> av=date(day, month, year).strftime('%d %B %Y') You are calling two functions here: date and strftime so one of those is wrong. Break the line in two and see if that...
28 Aug 2022 by Richard MacCutchan
I gave you the answer to this two days ago at Python date validation program - output query[^].
19 May 2015 by huy cao
Hello my friend.My project have a big mistake. when i insert a new data, my Datetime.now is returned bad values. Example, when insert: 05/20/2015. It will be back 2 day: 05/18/2015.This is my Code. Data: public bool add(Bill_DTO bill_dto) { try { SqlCommand...
19 May 2015 by Dianne Ramos
DateTime.Now gets the date and time on your/client's computer. Are you sure that the computer you are using is in current date and time?
19 May 2015 by DamithSL
change your sql statement to get sql server date and insert as below INSERT INTO BILL('ID_BILL,TIMECOMING') VALUES(@ID_BILL,GETDATE())note that now only ID_BILL need to set as parameter.
7 Jul 2015 by Pavel Durov
Tip about converting .NET DateTime to Unix double timestamp and vise versa - on .NET
5 Jun 2011 by thatraja
Display Date Time in 12/24 hour time format in C#/VB.NET
3 Nov 2014 by muniprasad
I came across Sq-lite database.I found our date time is stored in 18 digit time-stamp.Please help me how to convert it to Local Time. (I tried to convert it(No.of milliseconds from 1900). But i did not get it.It shows 29 days difference. I added 29 days of milliseconds to time. But time...
3 Nov 2014 by ArunRajendra
I don't its possible check this reference in msdn. http://msdn.microsoft.com/en-us/library/ms182776%28v=sql.90%29.aspx[^]
3 Feb 2021 by kelzi
I coudn't convert 4 bytes Hex value to datetime format. FA 5B 04 00 = 31.12.2020 18:00 F9 5B 04 00 = 31.12.2020 17:00 E1 05 03 00 = 30.06.2011 17:00 21 06 03 00 = 01.07.2011 09:00 I think first change to Float or Int32 - Little Endian...
2 Feb 2021 by OriginalGriff
At a guess - and that's all it can be from two so similar samples - it looks a bit silly. The only difference between the two values is one hex digit - a "9" changes to a "A" while the resulting date changes by one hour - which would imply that...
3 Feb 2021 by Patrice T
Just a guess: FA 5B 04 00 = 31.12.2020 18:00 F9 5B 04 00 = 31.12.2020 17:00 E1 05 03 00 = 30.06.2011 17:00 21 06 03 00 = 01.07.2011 09:00 ^ this look like the month - 1 Need more samples and details, where does it come from ? Try couples of...
21 Jun 2017 by ilostmyid2
In a Windows application form, I need to put a time picker. I think I may select between System.Windows.Forms.DateTimePicker or Telerik.WinControls.UI.RadDateTimePicker. It's not to be used to select a date. It's to be used a time in a 24-hours. But the time should be aligned in half-an-hour,...
21 Jun 2017 by Richard MacCutchan
See the Remarks section at DateTimePicker Class (System.Windows.Forms)[^]. [edit] Set the properties according to the remarks in the link above to show a simple up down time control, and add the following code to the ValueChanged event handler: DateTime dt = dateTimePicker1.Value; int mins =...
11 Oct 2014 by Doughnatch
I searched for codes to change system date but it's not working. What's wrong with this code?Private Structure SYSTEMTIMEDim wYear As ShortDim wMonth As ShortDim wDayOfWeek As ShortDim wDay As ShortDim wHour As ShortDim wMinute As ShortDim wSecond As ShortDim...
12 Oct 2014 by leon de boer
As CHill60 discusses read the documentation on the call. If you are going to play on the Win32 API at least bother to read the documentation on the callshttp://msdn.microsoft.com/en-us/library/windows/desktop/ms724942%28v=vs.85%29.aspx[^]RemarksThe calling process must have the...
3 Apr 2017 by clausont5
This should be an easy one but I am missing something and have been working on this for two days now.I am trying to insert a date/time in a short date format (date/time mm/dd/yyyy) into an access database and I get the "Data type mismatch in criteria expression" every time. If I comment out...
1 Jan 2011 by OriginalGriff
Firstly, use Parameters.AddWithValue instead of Parameters.Add - the later is depreciated.Secondly, instead of reading a date from a text box into a string, use DateTime.TryParseExact instead to convert it to a DateTime - you can then use that directly with the "startday" instead of using a...
1 Jan 2011 by clausont5
Thank you for the suggestion here but apparently I don't know how to use .AddWithValue as when I try to change .add to .AddWithValue, it gives me an error bc30455 argument not specified.Will using DateTime.TryParseExact, will that insert the date into the database in the format "MM/DD/YYYY"?...
1 Jan 2011 by Manfred Rudolf Bihy
Problem is OleDBCommand does not work with named parameters.You have to insert a question mark instead. When you add the parameters via:myOleDBCmd.Parameters.Add(Object obj, SqlDBType sqltype)You have to add them in the exact order the question marks appear in. Since named parameters...
1 Jan 2011 by clausont5
I found the problem: I had declared the textbox as a string rather than a date.This thread can be closed - it is answered.
23 Oct 2013 by thongla
I have a text file with this content08:00 - 09:3009:45 - 11:1511:30 - 13:0008/04/1314:00 - 15:3015:45 - 17:1517:30 - 19:00MIS (CH27) UMMIS (CH27) UMWith each empty line corresponds to one day in week, 08/04/14 is the first day of the week. I want to read...
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
15 Feb 2014 by kool15th
I have a application which saves date and time into sql server 2008 database, than those values are fetched within the selected time range i.e, from Date and To date. The query searches into database that if today's date lie between the selected date range, if yes than perform task.The issue...
15 Feb 2014 by Tadit Dash (ତଡିତ୍ କୁମାର ଦାଶ)
DateTime dt = this.dateTimePicker1.Value.Date;But this will also contain default time that is 12:00 AM as it is a DateTime Object.Otherwise you have to convert to string.
15 Feb 2014 by OriginalGriff
DateTime objects in .NET always have a time - they are stored as a number of milliseconds since an arbitrary point in time, so there is no way to have a DateTime without the Time unless you create a custom class.However, SQL does have a Date type which does not include the time. You could...
15 Feb 2014 by Gitanjali Singh
Try by setting CustomFormat// Set the Format type and the CustomFormat string.dateTimePicker1.Format = DateTimePickerFormat.Custom;dateTimePicker1.CustomFormat = "yyyy/MM/dd";Refer:http://stackoverflow.com/questions/1138195/get-date-from-date-time-picker[^]Hope this will work.
15 Feb 2014 by Krunal Rohit
First convert the date in string and give it a format as per your need and the convert it back to DateTime. See,String to DateTimeString MyString; MyString = "1999-09-01 21:34 PM"; //MyString = "1999-09-01 21:34 p.m."; //Depends on your regional settings DateTime MyDateTime;...
11 Dec 2013 by hgit
Hi am a newbie to this and looking for assistance. the following code applies to a where clause to a query whereby a post request exists.Everything is ok up until filtering by date.the field date_deliv_required is set to datetime in the database. variable datereq is a string in format...
11 Dec 2013 by King Fisher
string date = "01/08/2008";DateTime dt = Convert.ToDateTime(date); int month =dt.month;int year=dt.year;int days=dt.days;select * from table where MONTH(date_deliv_required)=month and YEAR(date_deliv_required)=year and DAY(date_deliv_required)=daysTry this,
11 Dec 2013 by Chris Ross 2
Personally, I'd use one of the technologies .Net offers for passing parameters into database queries. Use of parameters ensures that things like date formats and strings are handled correctly; they are also essential for preventing SQL injection attacks when your filter values are captured as...
12 Dec 2013 by JoCodes
Compare by converting into Datetime with the required format.var dateToCompare = DateTime.ParseExact(datereq, "yyyy-MM-dd", CultureInfo.InvariantCulture);deliverylists = deliverylists.Where(d => DateTime.Compare(d.date_deliv_required.Date, dateToCompare .Date)
9 Dec 2009 by Mark Graham
When searching between datetimes in SQL(or SQL in a Stored Proc) we can't just do:select * from where CreateTime >= @DateFrom and CreateTime
23 Apr 2015 by Member 11385046
I'm currently making an event program in VB.NET where the user can add daily/weekly/monthly/yearly events to a database.Their are two options :-Adding the occurrence x times to a StartDate.(http://i.imgur.com/LiRrZYy.png[^])-Adding the occurrence between a StartDate and an...
5 May 2015 by Gideon van Dyk
As mentioned in the comments, your code is vulnerable to SQL injections, recommend you use parameters.As for your problem, I think you need to adjust the code just slightly: Else 'Weekly mode with x times Dim aantal As Integer =...
6 May 2015 by Philippe Mori
Looking at the picture, we can easily see that the problem is related to the order MM/DD/YY vs DD/MM/YY. It look like the bad format is used whenever a date is valid in both cases.By the way, if yoy would follows the recommendation given by other to use parameters, it might fix the...
28 Jul 2018 by Member 13318869
Private Sub StockETDStdCalc() Dim DateSOP As Date Dim DateSOPFormat, DateDaySOP As String DateSOP = Nothing DateSOPFormat = Nothing DateDaySOP = Nothing DateSOP = DateTime.Now DateSOP = DateSOP.AddDays(+5) If...
28 Jul 2018 by OriginalGriff
That isn't even close - either you don't understand VB or you don't understand C#... Try using a code converter - there are several online, but this one's quite good: Code Converter C# to VB and VB to C# – Telerik[^] It gave me this: private void StockETDStdCalc() { DateTime DateSOP; ...
5 Jul 2018 by rikidev
Hi I have to run uses sum of time differences in the following format: StartEnd[0]: 08:50 StartEnd1: 10:30 StartEnd[2]: 12:30 StartEnd[3]: 15:30 result=(StartEnd 1 -StartEnd[0])+(StartEnd[3]-StartEnd[2]) How can I get the result value in the HH: mm format? What I have tried: C# Code:...
5 Jul 2018 by OriginalGriff
Convert each time to minutes: 08:50 ==> (08 * 60) + 50 ==> 530 10:30 ==> (10 * 60) + 50 ==> 650 Then (StartEnd 1 -StartEnd[0]) ==> 650 - 530 ==> 120 minutes and so on. When you have the result in minutes, it simple to use divide to get the hours, and modulus to get the minutes: int hours =...
5 Jul 2018 by Gerry Schmitz
TimeSpan ts0 = TimeSpan.Parse( "08:50" ); TimeSpan ts1 = TimeSpan.Parse( "10:30" ); TimeSpan ts2 = TimeSpan.Parse( "12:30" ); TimeSpan ts3 = TimeSpan.Parse( "15:30" ); int minutes = (int) ( ts1.TotalMinutes - ts0.TotalMinutes + ts3.TotalMinutes -...
5 Jul 2018 by Patrice T
Quote: Add the difference in hours and minutes in C# Hours are decimal, minutes are decimal, but a time (hours + minutes) is not decimal. But hours and minutes are linked: 1 hour is 60 minutes. So to do 'time arithmetic', you need to handle this particularity. You have mostly 2 possibility: -...
17 Dec 2012 by middelpat
Adding and subtracting with dates and times ignoring weekends
8 May 2014 by vivek murli
namespace Thermocoders_Licensing_System{ class TrialTimeManager { private string temp = ""; public TrialTimeManager() { } public void SetNewDate() { DateTime newDate = DateTime.Now.AddDays(31); temp = newDate.ToLongDateString(); StoreDate(temp); ...
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...
12 Nov 2013 by Mohamad M. Mohamad
I have a TextBox inside it a date dd/MM/yyyy formatI have a button when clicked I want to add one day to the date found in the textbox.Example TextBox: 15/09/2013 When I click I want the textbox text be 16/09/2013I used this code below but it started adding month when published on...
12 Nov 2013 by shyamnguitar
You can use this to subtract and add days to the existing data may be in your in a text box. Once you use these methods you get the values and u can print them or you can set teh text box with a fresh value.using System;class Program{ static void Main() { ...
12 Nov 2013 by phil.o
Private Sub MyButton_Click(sender As Object, e As EventArgs) Handles MyButton.Click Dim culture As New CultureInfo("fr-FR", false) '' Here I took french culture because I'm sure it represents the DateTime format the way you want, i.e. dd/MM/yyyy Dim myDate As DateTime myDate =...
16 Jun 2015 by Parazival
actually i have one checked datetime picker,one textbox,one dropdown(years,months,days)and my question is if user check the date timepicker textbox and dropdown both are shoud not available(disable) to enterdepend on date time picker auomatically age should be calculated and displayed in...
4 Apr 2017 by kkakadiya
Hello, in my Controller, json result returns start date as 04/04/2017 but when I print start date in AJAX call return in view it displays as /Date(1488133800000)/ I manipulated start date as below but it prints 4/4/2017.I need to print 04/04/2017. how can I do that? $.ajax({ url:...
4 Apr 2017 by Wessel Beulink
tr.append("" + SDate.ToString("dd-MM-yyyy"); + "");
4 Apr 2017 by Karthik_Mahalingam
try var str = '4/4/2017'; var parts = str.split('/'); var month = ('0' + parts[0]).slice(-2); var day = ('0' + parts[1]).slice(-2); var year = parts[2]; var result = month + '/' + day + '/' + year;
14 May 2014 by Member 10556609
Am New To Android . am having one edit text box for entering date time..if i enter date time .it will check date time format validation..Please Help Me any one..
17 Aug 2017 by ddgjgj
This is the model : e[DataType(DataType.Date)] public Nullable PublishDate { get; set; } This is the view : e @Html.DisplayNameFor(model => model.PublishDate) @Html.DisplayFor(model => model.PublishDate) ...
16 Aug 2017 by Namith Krishnan E
Try this while chaging the culture. Set newCulture as your changed culture CultureInfo newCulture = (CultureInfo)System.Threading.Thread.CurrentThread.CurrentCulture.Clone(); newCulture.DateTimeFormat.ShortDatePattern = "dd-MMM-yyyy"; newCulture.DateTimeFormat.DateSeparator = "-"; ...
17 Aug 2017 by Richard Deeming
If you want to control the format for a specific field, use the DisplayFormat attribute: DisplayFormatAttribute Class | Microsoft Docs[^] [DisplayFormat("dd-MMM-yyyy")] public DateTime? PublishDate { get; set; } (NB: DateTime? is a shorthand way of writing Nullable.) If you want to...
4 May 2013 by AhmedYehiaK
Hi everyone :),I have a web application that hosted on server in USA.My problem is when DateTime.Now called it retrieve the DateTime.Now at USA, but i want my application to retrieve the Egypt DateTime.Now (since all my users are in Egypt) without change any line of code by another...
4 May 2013 by Karthik. A
This is due to the "Culture" for your application. By default it is en-us. Check this how to from MSDN:http://msdn.microsoft.com/en-us/library/bb882561.aspx[^]This has a broader scope but helpful...
4 May 2013 by Avik Ghosh22
Use ust time + your time range from utc... like india 5:30...example: for India :select getutcdate()+'5:30'give the proper time of india... :)
17 Apr 2013 by klottim
Hello, have some problem with DateTime in Backgroundworker.Any solution for this one?I really need DateTime.This code don't work: private void bw_DoWork(object sender, DoWorkEventArgs e) { BackgroundWorker worker = sender as BackgroundWorker; ...
17 Apr 2013 by Pheonyx
It would appear you are cross threading the application. You need to use delegates if you want other threads to be able to interact with user controls (even just reading them).You could take advantage of this code snippetCode Snippet private void button1_Click(object sender, EventArgs...
10 Feb 2014 by Summeronthebeach
I know the below code is supposed to format the FormattedTextField but it doesn't seem to do anything to the form (shown in the picture below). I was wanting, when the form loaded: the text field to look something like this00/00/2014 - 00:00 amWhere the user is able to- enter...
2 Mar 2017 by BeginnerCoderPete
This is the code for my BindingSource.FilterDim FilterStartMonth As Date = DateTimePickerTodaysDateTime.Value.Date Dim Filter2MonthsBack As Date = DateTimePickerTodaysDateTime.Value.AddMonths(-2).Date ClockInTimesBindingSource.Filter = "EmployeeID = " &...
2 Mar 2017 by Graeme_Grant
Your system Culture settings usually deturmines the ToString format. You can check it by doing the following:Dim culture = Globalization.CultureInfo.CurrentCultureDim CultureName = culture.NameDim shortDateFormatString = culture.DateTimeFormat.ShortDatePatternDim longDateFormatString =...
8 Aug 2015 by Klinkehoffen
Hi there,Does anyone know if there is a third party auto-expire app or piece of code that I could use to add an auto-expire function to my Blogger blog posts?I want to create an "always on top" for my "Welcome" message on my blogroll summary. I usually make about three posts each week, and...
10 Oct 2015 by Mohammad Dayyan
MdPersianDateTime is a jQuery plugin to create Persian DateTimePicker with bootstrap popover
15 May 2015 by arunsiddhu1992
I,ve used AJAX calender extender to enter date but after adding this contol my button does nothing on click event.my code isASPX. function...
13 Jul 2017 by Member 13302374
Hi, I have been given the date and time of an appointment and I need to return how many days it (the appointment) is in the future. The answer must be in FULL days; for example, at 11 PM tonight, an appointment at 9 AM tomorrow would be 1 day (and not 10 hours). I have attempted the question...
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; } ...
13 Jul 2017 by Richard MacCutchan
This is basically the same issue as C# - calculate number of hours away from a deadline[^] except that this time you are looking at Days. Given that you want full or partial days you just need to divide the hours by 24 and add 1 if there is a remainder. Simple maths really.
14 Jul 2017 by Member 13302374
Hi, I need to convert how many 'days Old' someone is (e.g. 3 years old = 1,095 days old) to a 'date of birth' answer i.e. dd/MM/yyyy. I have tried many different ways how to do this, but to no avail (yet) - e.g. using a mathematical formula but it gets a bit complicated, especially when...
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)); }
14 Jul 2017 by F-ES Sitecore
int daysOld = 1095; DateTime dob = DateTime.Now.AddDays(daysOld * -1);
14 Jul 2017 by User 7407470
public static string GetBirthDate(int daysOld) { // DateTime.Now.AddDays(-daysOld).To... has many format options // beware AddDays: daysOld conversion to type double return DateTime.Now.AddDays(-daysOld).ToString("dd'/'MM'/'yyyy") }
11 Jul 2017 by Member 13302374
Hi, I have been asked to return the string representation of the given DateTime in the format: Monday, July 30, 2013 14:18:00 (AM/PM). Please see my code below. I am not far off the right answer, but I must have gone wrong somewhere in my syntax. Corrections and any accompanying explanations...
11 Jul 2017 by TheRealSteveJudge
Why don't you use a standard format? e.g. var ci = new CultureInfo("en-US"); var dateTimeString = now.ToString("F", ci); Don't forget to use the right CultureInfo. Another one: var dateTimeString = now.ToString("dddd, MMMM dd yyyy HH:mm:ss tt", ci);
11 Jul 2017 by Member 13302374
Hi there, A question given to me is asking me to return the total minutes passed today until now (i.e. the time right now). I know the right code format is myDateTime.TimeOfDay.TotalMinutes. which will give us the number of minutes that have passed in the day represented by myDateTime starting...
11 Jul 2017 by F-ES Sitecore
public static int GetTotalMinutes() { return (int)DateTime.Now.TimeOfDay.TotalMinutes; }
5 Jul 2016 by Member 12226114
I am developing small winform app to send an automatic email to customer at a specific time everyday.The customer will set the time from the UI, so when the system time = time set by customer, my app will send email. I included a datetimepicker in which customer set his desired trigger time. The...
5 Jul 2016 by Richard MacCutchan
What is the purpose of the textboxes? All the app needs on load is to get the time value from the user. It then saves that time as a variable, and can then compare that to the clock time, in order to decide when to send the email.
5 Jul 2016 by CPallini
I suggest you to use the Windows Task Scheduler[^] instead.
6 Mar 2014 by Tanna Jayesh
I would like to compare two dates excluding years.Ex.Input: FromDate: 01 March, ToDate: 05 Marchthen all records between these two dates should be come whether there is any year. It does not matter.So please anyone can help me in this issue.Thanks in advance.
6 Mar 2014 by CHill60
You could artifically introduce the year for your comparison. E.g. string s1 = "15/03"; string s2 = "01/03"; DateTime d1 = DateTime.Parse(s1 + "/2014"); DateTime d2 = DateTime.Parse(s2 + "/2014"); TimeSpan t =...
6 Mar 2014 by ravikhoda
in c# you can saperate the day part and month part of both the dates and can compare that and leave year as it is. Datetime d1 = somedate;Datetime d2 = someotherdate;int day1 = d1.Day;int day2 = d2.Day;int Month1 = d1.Month;int Month2 = d2.Month; if(day1 == day2 && Month1...
13 Apr 2015 by jaylisto
i have asp.net c#computing total number of hours.since i will pull the data from a database as a string value, i must convert that string to a datetime which seems not working at all.the value 2015, 4, 12, 22, 28, 20 must be a string ( i will pull the data from a database in a later...
13 Apr 2015 by phil.o
You can try DateTime.Parse() method with all its overloads.DateTime.Parse Method[^]DateTime.TryParse can be an option, too.
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...
22 Oct 2012 by mrjohnk
Hi, how do I save changes been made on datagridview. Bellow is the code have I have so far. private void refreshInvoice() //Load all Invoice result. { SqlDataAdapter dataAdapter = new SqlDataAdapter("select ID_Invoice, Description_Invoice, Amount_Invoice,...
23 Oct 2012 by Samsani.v.s.Durga Prasad
Hi Initially you will get the by using below code DataSet ds = new DataSet(); static SqlConnection con = new SqlConnection("user id=sa;password=just4fun;database=sdp;data source=sitt244"); static SqlCommand cmd = new SqlCommand("select * from employee ", con); ...
23 Oct 2012 by Tushar22Patel
HiStep - 1 Take DatasetStep - 2 Fill Dataset using appropriate select statmentStep - 3 Assgin dataset to Gridview(AllowAddNewRow Property to True)Update Existing Dataif you update existing data then use Update() method of sqladapter object.Insert new dataFirst Add new...
12 Nov 2019 by Member 13132705
I am working on code in C# where I used OLEDB connection string to connect MS access database. I have a form where I show data from database in datagridview on some criteria. Below are criteria: a) Person (come from database in) b) Process (come from database in textbox) c) From Date...
12 Nov 2019 by OriginalGriff
Instead of IN, use BETWEEN: DateColumn BETWEEN startDate AND endDate And more importantly: Never concatenate strings to build a SQL command. It leaves you wide open to accidental or deliberate SQL Injection attack which can destroy your entire database. Always use Parameterized queries instead....
12 Nov 2019 by RickZeeland
Try to format the date values like this: Where [P Date] Between #" + dateTimePicker4.Value.ToString("yyyy'/'MM'/'dd") + "# And #" + dateTimePicker5.Value.ToString("yyyy'/'MM'/'dd") + "#"
24 Jan 2013 by ure fowei
Hi,I am working on a C# project and part of which is to read a byte data from both UNIX and WIN machines.Some byte data correspond to date and time. So here is the task that I need I do.1. Convert byte to long.2. Convert long to DateTime3. Convert DateTime to...
26 Jan 2013 by Jeoshua
It's not a C# problem, it's actually a Windows vs UNIX thing.Unix generally uses UTC hardware time, meaning that the hardware clock stores the time in UTC (GMT, Zulu, +0, etc) and is converted to a readable format according to which time zone the computer says it's in once the information is...