dates

How do I compare dates in Javascript?

I have the following situation: I have a certain function that runs a loop and does stuff, and error conditions may make it exit that loop. I want to be able to check whether the loop is still running or not. For this, i'm doing, for each loop run: LastTimeIDidTheLoop = new Date(); And in another function, which runs through SetInte...

Convert US date format to ANSI SQL date format (YYYY-mm-dd)

I want to convert user-submitted date format (mm/dd/yyyy) to a MySQL date format (YYYY-mm-dd). Submission is via a simple PHP form direc tto MySQL database. ...

Subtraction of MySQL times inconsistent on different machines.

I have a MySQL query structured as follows: SELECT time(c.start_time), time(c.end_time), time(c.end_time) - time(c.start_time) as 'opening_hours' FROM my_shop c; The data in start and end time is 1970-01-01 07:00:00 and 1970-01-01 19:00:00 respectively. On my local machine this this query returns: | 07:00:00 | 19:00:0...

If I wanted to work using dates and time going millions of years into the past/future how would I do it?

If I wanted to work using dates and time going millions of years into the past/future how would I do it in C/C++/C#? For example say I was working on an algorithm to see if a comet was going to hit the earth? Are there commercial or open source libraries that do this? Most DateTime values only work for a few years. Unixes will run out...

Delphi date comparison

What is the difference between the two functions "IsSameDay" and "SameDate" in the Delphi DateUtils library? ...

Add date without exceeding a month.

Hello. I hope someone could help me on this. I want to add a month to a database date, but I want to prevent two jumping over month on those days at the end. For instance I may have: Jan 31 2009 And I want to get Feb 28 2009 and not March 2 2009 Next date would be March 28 2009 Jun 28 2009 etc. Is there a function that...

Parsing unsupported date formats in via Cocoa's NSDate

With the Cocoa framework how can I parse @"2008-12-29T00:27:42-08:00" into an NSDate object? The standard -dateWithString: doesn't like it. ...

System constant for the number of days in a week (7)

Can anyone find a constant in the .NET framework that defines the number of days in a week (7)? DateTime.DaysInAWeek // Something like this??? Of course I can define my own, but I'd rather not if it's somewhere in there already. Update: I am looking for this because I need to allow the user to select a week (by date, rather than wee...

Weird Behavior when using between? method for dates

Open up a Rails console and enter this: 2.weeks.ago.between? 2.weeks.ago, 1.week.ago Did it give you true or false? No really, try it a few more times and it will give you different answers. Now, I'm thinking that because we're comparing 2.weeks.ago with 2.weeks.ago, the time between evaluating the two statements is causing this beha...

Filtering a complete date in django?

There are several filter methods for dates (year,month,day). If I want to match a full date, say 2008/10/18, is there a better way than this: Entry.objects.filter(pub_date__year=2008).filter(pub_date__month=10).filter(pub_date__day=18) ...

C# Dates - Databases, Display and Localization

What are some Date (& Time) format best practices when wanting to adhere to localization in a new application. For example, what format do you use to write dates to the database. How do you display the following to the user using their own locale settings once the date has been obtained from the database. ShortDate LongDate DateTime ...

Unable to parse a DateTime

I'm trying to parse a date/time string using DateTime.ParseExact. It works everywhere, except on one machine - it just will not parse on that machine. The question is: Why? What could be different on that machine so that it will cause this behaviour? Here are some things that I've already looked at: The CultureInfo is passed to DateTi...

Parsing Ambiguous Dates (Language Independent)

I am curious what would be the best way to handle an ambiguous date string in any given language. When pre-validating your user input isn't an option, how should MM/dd/YYYY dates be parsed? How would you parse the following ambiguous date and for what reason (statistical, cultural, etc)? '1111900' as Jan 11, 1900 [M/dd/YYYY] or Nov 1,...

How do compare dates in Perl?

I have two dates (parsed using str2time). How can I tell if one is after the other? ...

Convert unix timestamp to julian

How can I convert from a unix timestamp (say 1232559922) to a fractional julian date (2454853.03150). I found a website ( http://aa.usno.navy.mil/data/docs/JulianDate.php ) that performs a similar calculation but I need to do it programatically. Solutions can be in C/C++, python, perl, bash, etc... ...

Get a list of dates between two dates

Using standard mysql functions is there a way to write a query that will return a list of days between two dates. eg given 2009-01-01 and 2009-01-13 it would return a one column table with the values: 2009-01-01 2009-01-02 2009-01-03 2009-01-04 2009-01-05 2009-01-06 2009-01-07 2009-01-08 2009-01-09 2009-01-10 2009-01-11 2009-01-12...

ASP.NET, SQL Server, LINQTOSQL and Date formats

I am setting the locale of my .net application via: string userLocale = Web.Helpers.LocaleHelpers.GetBestRFC3066Locale(this.Context.Request.UserLanguages); if (userLocale != String.Empty) { System.Threading.Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.CreateSpecificCul...

Return day int value from function?

i try to write any code about days: function xyz("13.02.2009") { return value= 6; } function xyz("12.02.2009") { return value= 5; } function xyz("14.02.2009") { return value= 7; } but how? tihs method is good but i need C# times specific codes(like timespan...) DayOfWeek day = DateTime.ParseExact("13.02.20...

Best way to calculate dates from results?

I have a database table. It has several hundred entries and each entry is timestamped. I'm looking to only output each day and not have it duplicate any days. Data: 2009-02-04 06:20:27 2009-02-04 06:20:27 2009-02-05 06:20:27 2009-02-07 06:20:27 2009-02-07 06:20:27 2009-02-07 06:20:27 Output should only be (time is irrelevant): 20...

Recommend a JS calendar widget that handles both date and time?

I'm working on a Web app where users need to input a date and time. I've used this calendar widget before and it works fine: http://www.dynarch.com/projects/calendar/ However, it hasn't been updated since 2005. I'm wondering if anyone knows of a better one. The calendar in jQuery UI doesn't handle times. Only dates. I need something t...