datetime

Count number of Mondays in a given date range

Given a date range, I need to know how many Mondays (or Tuesdays, Wednesdays, etc) are in that range. I am currently working in C#. ...

Data binding formatting to a DateTime column

I have a textbox with the Text property bound to a dataset column with the DataType set to System.DateTime. The FormatString on the Binding is set to dd-MM-yyyy. When the user enters a date it attempts to convert it to a date but can come up with some strange values for a seemingly invalid date. For example: textBox1.Text = "01-02-200...

How to convert UNIX timestamp to DateTime and vice versa?

As the title says really. There is this example code, but then it starts talking about millisecond / nanosecond problems. http://blogs.msdn.com/brada/archive/2004/03/20/93332.aspx Edit: This is what I've got so far: public Double CreatedEpoch { get { DateTime epoch = new DateTime(1970, 1, 1, 0, 0, 0, 0).ToLoca...

How to check a date in classic asp

I have a variable last_login and want to output a message if the last login was yesterday, today or elsewise output the date. The last two cases are clear but how can I check if a given date in classic asp was yesterday? I'm blockheaded right now... ...

Format columns for ASP.Net GridView based on data type.

I have a very simple ASP.Net page that acts as a front end for a stored procedure. It just runs the procedure and shows the output using a gridview control: less than 40 lines of total code, including aspx markup. The stored procedure itself is very... volatile. It's used for a number of purposes and the output format changes regularl...

How can I convert a varchar field of the form: YYYYMMDD to a datetime in T-SQL?

How can I convert a varchar field of the form YYYYMMDD to a datetime in T-SQL? Thank you. ...

How can I insert current date and time into a file using Emacs?

What commands in Emacs can I use to insert into the text buffer of a file the current date and time? (For example, the equivalent in Notepad is simply pressing F5 which is about the only useful feature for Notepad!) ...

Splitting time + duration into intervals in t-sql

Hi, Does anyone know of a simple method for solving this? I have a table which consists of start times for events and the associated durations. I need to be able to split the event durations into thirty minute intervals. So for example if an event starts at 10:45:00 and the duration is 00:17:00 then the returned set should allocate 15 ...

What is the correct format to use for Date/Time in an XML file (.NET)

What format do I use for Date/Time when writing to an XML file using .NET? Do I simply use DateTime.ToString(), or do I have to use a specific format? ...

Converting datetime to POSIX time

How do I convert a datetime or date object into a POSIX timestamp in python? There are methods to create a datetime object out of a timestamp, but I don't seem to find any obvious ways to do the operation the opposite way. ...

How to convert a string "yyyy-MM-ddZ" to a date time with .net?

I am having problems converting a string in the format "yyyy-MM-ddZ" using VB.net. For example I have the string "2007-10-21Z". Using CDate or TryParse it comes out to 10/20/2007 instead of 10/21/2007. I'm not understanding how the Z affects the date string so that when it is parsed it results in the day before. From what I understan...

How can I find the time since an event happened?

The event returns a standardized timestamp in the format of "Sat Oct 25 21:55:29 +0000 2008" How can I compare this with the current time in PHP so that it gives me the result in a form like "It has been 15 minutes!" or "It has been three days!" Also, how can I get the current time? ...

What is the best way to calculate page hits per day in MySQL

On my blog, I display in the right nav the 10 most popular articles in terms of page hits. Here's how I get that: SELECT * FROM entries WHERE is_published = 1 ORDER BY hits DESC, created DESC LIMIT 10 What I would like to do is show the top 10 in terms of page hits per day. I'm using MySQL. Is there a way I can do this in the database...

DateTime format on hosting server.

I recently switched my hosting provider and due to the time zone that the server is now in, my code has stopped working. The hosting server reports in Pacific time, However, my code needs to work with GMT as my site is for the UK market. So, all my displays and searches need to be in the format dd/MM/yyyy How can I account for the dif...

Handling WCF Deserialization of DateTime objects

We've got a scheduling application running that calls a WCF service to run nightly jobs. A large number of these include information about the current business date. For business reasons the scheduling server is set to GMT, but our service is running on servers set to NY time. This raises a problem; the dates are being passed to our...

DateTime.UtcNow.Ticks sometimes jumps a remarkable amount

In a tightly looped test application that prints out the value of DateTime.UtcNow.Ticks, I notice that the value will jump a remarkable amount once every hour or so. Look closely at the following sample data: 1:52:14.312 PM - 633614215343125000 1:52:14.359 PM - 633614215343593750 1:52:14.421 PM - 633614215344218750 1:52:14.468 PM - 633...

When Would You Prefer DateTime Over DateTimeOffset

A few months ago I was introduced to the new DateTimeOffset type and was glad DateTime's flaws with regard to time zones were finally taken care of. However, I was left wondering if there were any overhead or problems that could occur from using this new type. I work on a multi-locale web application. Does anyone know of anything that ...

Format RSS pubDate as .NET DateTime

How would I format the standard RSS pubDate string as something closer to ASP.NET's DateTime? So, from this: Wed, 29 Oct 2008 14:14:48 +0000 to this: 10/29/2008 2:14 PM ...

How to get a build date for an ASP.NET application?

Jeff wrote about getting a file version/datestamp a while back. Visual studio doesn't increment builds unless you close/reopen the solution, so grabbing the timestamp seems to be the best way to verify what build you are using. I ported the solution to C# // from http://www.codinghorror.com/blog/archives/000264.html protected D...

Mysql strip time component from datetime

I need to do a date comparison in Mysql without taking into account the time component i.e. i need to convert '2008-11-05 14:30:00' to '2008-11-05' Currently i am doing this: SELECT from_days(to_days(my_date)) Is there a proper way of doing this? ...