datetime

best way to keep track of an ordered smalldatetime column

I know the difference between smallDateTime and timeStamp. Right now I am using smallDateTime because the precision is good enough for my needs. But the problem is that I still need to keep inserted items in order and smallDateTime is mixing things up if the inserts come too close to each other. Is it an acceptable practice to use both ...

How can I convert two strings to DateTimes and compare them in VB.NET?

String comes back from the database with a format: '00/00/0000' I need to then compare it to a date that the user has entered in the same format. How do I make the conversion and compare the two dates? ...

PHP/MySQL: Convert from YYYY-MM-DD to DD Month, YYYY?

Hi, I have in a MySQL table a DATE column that represents the date in this format: YYYY-MM-DD. I wanto to retrieve the date from the database using PHP but display it like this: DD Month, YYYY. From '2009-04-13' to '13 April, 2009' for example. Witch is the best way to do it?? ( I know how to get the date from the DB. I only need to k...

How can you save time by using the built in Date class?

The intention of this question is to gather solutions to date / time calculation using the built in Date class instead of writing long complicated functions. I’ll write some answers myself, and accept an answer if anyone comes up with something very clever. But this is mostly meant as a collection of solutions, since I often see overly ...

java string to datetime conversion issue

I can't seem to see the problem with the example code below. For some reason seems to be ignoring the year and saying the dates are the same, as can be seen in the output below. I must be missing something simple. 01/28/2006 01/16/2007 Tue Apr 01 00:00:00 PDT 2008 Tue Apr 01 00:00:00 PDT 2008 done import java.util.*; impo...

Getting non-existant month/week/year when using MySql group by clause with month/week/year date functions.

I am trying to implement a query where I am using aggregates to sum certain values and then group by mysql date functions (month | year | week). Those group by clauses don't return non-existant months OR year OR week respectively for obvious reasons. I was wondering if there is a way to get them? ...

How do I create a datetime in Python from milliseconds?

I can create a similar Date object in Java by java.util.Date(milliseconds). How do I create the comparable in Python? ...

How Do I Serialize DateTime Objects in .NET in a Standards Compliant Way

My goal is use the .NET DateTime object (in C#) and have that be serialized to and parsed from a string (for use in XML) in a way that is standards compliant. The specific standard I have in mind is the ISO 8601 standard for representing dates and times. I want an easy to use solution (preferably, one method call each way) that will co...

Help with Google App Engine query and datetime

I use the following data: date latitude route name longitude 2009-04-11 00:50:31.640000 40.80708 White Loop 86 -77.85891 2009-04-11 00:50:27.718000 40.80708 White Loop 86 -77.85891 2009-04-11 00:50:01.562000 40.80708 White Loop 86 -77.85891 2009-04-11 00:49:48.765000 40.80708 White Loop 86 -77.85891 ...

Help with Tricky Linq Group by for time ranges

I have a class that represents a shift that employee's can work: public class Shift { public int Id { get; set;} public DateTime Start {get;set;} public DateTime End { get; set;} public DayOfWeek Day { get; set;} } And say I have a list of these shifts for a single employee: List<Shift> myShifts; I know I can get group the shifts ...

Not getting correct time from UniversalDateTime

I send a vcal through mail in web application with convert datetime to universal datetime. If i run web application locally (local sevser in India) i get correct time in my vcal. But run appication live (server in US) then not get corret time with a difference of 1 and half hour.Please suggest me. code : Dim result As StringBuilder = N...

Changing dateformat on a SQL Server DB and not on whole server to dd/mm/yyyy

Hi there, can anyone help, we have a sql server 2005 database installed (actually its an sql server 2000 attached to an sql server 2005 server) with the default server language language USA with dateformat like mm/dd/yy and we really need to keep it this way but currently just uploaded a new database to the server and this needs to have...

How to determine tomorrow's date in J2ME for use in a DateField?

I basically want to be able to show tomorrows date I have this which shows today date private Date date = new Date(); i tried this but this gave me jan 1 1970 private Date date = new Date(+1); please help ...

Integer representation for day of the week

I would like to convert a date object its integer representation for the day of week in C#. Right now, I am parsing a XML file in order to retrieve the date and storing that info in a string. It is in the following format: "2008-12-31T00:00:00.0000000+01:00" How can I take this and convert it into a number between 1 and 7 for the day o...

Is there anything like Chronic available in PHP?

I am looking for a very robust datetime parser, similar to Ruby's Chronic, but for PHP. strtotime() isn't cutting it for a lot of the edge cases I'm seeing in my project. Anyone know of any good libraries? Ideally: - PHP 5 OOP - well documented - fast and stable Thanks! ...

how to convert string into time format and add two hours

Hi, I have the following requirement in the porject. I have a input field by name startdate and user enters in the format YYYY-MM-DD HH:MM:SS. I need to add two hours for the user input in the startdate field. how can i do it. Thanks in advance ...

Calculate total hours using DateTime columns in DataGridView

I'm struggling a bit with a calculation I need to do en every row in a datagridview. What I want is to go through all rows in a datagridview that has two columns with datetimes. One representing a LogInTime and one representing a LogOutTime. I would like to get the total number of hours and minutes between all log in times and log out ti...

Migrating an Access data table to SQL Server 2005

I used the standard import / export tool to bring a table into my SQL database. The dates all came over as CHAR types. Now, I keep getting a conversion error stating the CHAR to datetime resulted in an out of range condition. Help please. ...

What date formats does the PHP function strtotime() support?

I really like the PHP function strtotime(), but the user manual doesn't give a complete description of the supported date formats. It only gives a few examples like "10 September 2000", "+1 week 2 days 4 hours 2 seconds", and "next Thursday". Where can I find a complete description? ...

Testing time sensitive applications in Python

I've written an auction system in Django. I want to write unit tests but the application is time sensitive (e.g. the amount advertisers are charged is a function of how long their ad has been active on a website). What's a good approach for testing this type of application? Here's one possible solution: a DateFactory class which provi...