Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Everything / DateTime

DateTime

DateTime

Great Reads

by Pavel Durov
Tip about converting .NET DateTime to Unix double timestamp and vise versa - on .NET
by thatraja
Display Date Time in 12/24 hour time format in C#/VB.NET
by Graham Wilson
An exercise to measure the drift in the time-of-day clock on a Windows PC using the periodic timer
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 <= @DateToIf your search is date inclusive and you're not concerned with time, which most users aren't, then you need to add a little extra...

Latest Articles

by Pavel Durov
Tip about converting .NET DateTime to Unix double timestamp and vise versa - on .NET
by thatraja
Display Date Time in 12/24 hour time format in C#/VB.NET
by Graham Wilson
An exercise to measure the drift in the time-of-day clock on a Windows PC using the periodic timer
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 <= @DateToIf your search is date inclusive and you're not concerned with time, which most users aren't, then you need to add a little extra...

All Articles

Sort by Score

DateTime 

by Pavel Durov
Tip about converting .NET DateTime to Unix double timestamp and vise versa - on .NET
by thatraja
Display Date Time in 12/24 hour time format in C#/VB.NET
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 <= @DateToIf your search is date inclusive and you're not concerned with time, which most users aren't, then you need to add a little extra...
by middelpat
Adding and subtracting with dates and times ignoring weekends
by InActive
How to use the .NET DateTime class in C++ to generate a basic calendar via a console program
by Pranay Rana
Convert DateTime string to DateTime variable
by Dudyalu Sravan Kumar Reddy
In this tip, we will learn about using DateTime picker in ASP.NET Core using JQuery Plugin. Let’s start with a step by step approach.
by Bib34770
What about that :CultureInfo.CurrentCulture.Calendar.GetWeekOfYear(pd_date, CalendarWeekRule.FirstFourDayWeek, DayOfWeek.Monday);
by Jani Giannoudis
Here another approach taken from my article Time Period Library for .NET[^], which returns addditional the year of the week.// ------------------------------------------------------------------------public enum YearWeekType{ Calendar, Iso8601,} // enum YearWeekType //...
by OriginalGriff
Strangely, the .NET DateTime does not provide a Week Number. This extension rectifies this.
by Gustav Brock
DateTime Extension method to give the right week number
by Er. Puneet Goel
When you are dealing with Date&Time input from user, it's always complicated to handle the Date&Time format. You are not sure about how you will handle the user input format. So, here is the solution.
by Bohdan Stupak
Explanation of how DateTime.TryParse behaves with ISO-8601 format
by Jani Giannoudis
Calculate the number of whole working days between start and end with support of holidays and holiday-periods.
by Go Cova
public static int GetFullWorkingDaysBetween(DateTime firstDate, DateTime lastDate, IEnumerable holidays){ if (firstDate > lastDate)// Swap the dates if firstDate > lastDate { DateTime tempDate = firstDate; firstDate = lastDate; lastDate =...
by Emmanouil Gimissis MSc ICSD
Fast calculation of week days between two dates using DateDiff
by R. Giskard Reventlov
When using DateTime with SQL Server, I often forget what the parameters are that allow formatting DateTime in specific ways. When that happens, I fire up this code fragment in SQL Server Management Studio and it neatly lists out every possible parameter with example output.declare @Loop...
by #realJSOP
Find the date of a specified federal holiday for a given year.
by Gustav Brock
This is an alternative to using LINQ for "Find the count of a weekday between two dates without iterating/looping".
by Ravi LVS
Find the count of a weekday between two dates without iterating/looping
by Prerak Patel
Single line in Linq This gets you the number of weekdays, i.e., Monday to Friday between given two dates.[VB]Dim dt1 As New Date(2011, 1, 1)Dim dt2 As New Date(2011, 1, 15)Dim days As Integer = (From d As Date In _ (Enumerable.Range(0, 1 +...
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...
by George Swan
Is it easier to start from the next targeted day? Subtract that date from the end date. If the result is negative, return 0 otherwise return the quotient of the difference in days between the two dates divided by 7 plus 1.public static int findWeekCount(DateTime startDate, DateTime toDate,...
by rld1971
I like things simple for debugging purposes... LINQ implies a list or some iterable thing, but that's just me. I think this works:static int CountDayOcurrence(DateTime start, DateTime end, DayOfWeek day){ var wstart = start.AddDays(7 - (int) start.DayOfWeek); // Sunday after start...
by K Quinn
Didn't read it very closely, haven't tested it very thoroughly, but, you get the idea:public int GetNumberOfRecurrances(DayOfWeek weekDay, DateTime startDate, DateTime endDate){ int distanceToFirstInstance = ((int)weekDay - ((int)startDate.DayOfWeek)); //determine integer...
by NightWizzard
Explained step by step
by SA - Hibbert
Return all records between two dates that include time in SQL.
by dynamichael
Use extension methods, Encoding, and BitConverter to read and write native types on an IO.Stream object
by maxcellent
Java date generation with Lamma date library (1)
by maxcellent
This article discusses basic date sequence generation with Lamma date library in Java
by Ed Nutting
JavaScript Date Validation
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...
by musicm122
Datejs could be a possible alternate helper, or if you are going the way of jQuery, check out jQuery validation engine.
by Jason Sobell
The manipulation of dates in an application is not as straightforward as it first appears, but some simple understanding of the way Dates apply to real-world usage can help avoid all sorts of nasty issues down the line.
by Suvendu Shekhar Giri
Difference between MySQL DATETIME and TIMESTAMP datatypes
by xibao
Code to produce holidays for NYC Stock Exchange.
by Hamid Mosalla
PersianCalendarPlus is a simple wrapper around System.Globalization.PersianCalendar. In this tip, I'm going to show you how you can use it.
by Dhol Gaurav
Problem and solution of add date into JavaScript with daylightsaving in different time zone
by Bhis
Read XML File and change date contents
by Gary Bilkus
How to get Silverlight 4 to display dates by default using the regional settings in the Control Panel.
by DiponRoy
Split date time ranges into days or possibly other ranges using CTE in SQL Server
by Charan_Kumar
Splitting dates of different months in Asp.Net
by Jani Giannoudis
Show a TimeSpan by calendar periods
by Jamie Highfield
WinForms .NET Time Chooser grid control.