datetime

Ge the most recent date from a list - Ruby

I have an array of Ruby Date objects. How can I find the most recent datetime and the oldest datetime? thanks ...

Joda-Time: How to get the next friday?

How can I get the next friday with the Joda-Time API. The LocalDate of today is today. It looks to me you have to decide whever you are before or after the friday of the current week. See this method: private LocalDate calcNextFriday(LocalDate d) { LocalDate friday = d.dayOfWeek().setCopy(5); if (d.isBefore(friday)) { return d.dayO...

user datetime setting as GMT, how to convert date to their localized setting?

In my users setting I have a dropdown with all the GMT dates for the user to select. In c#, how would I convert a datetime stored in the database to their GMT time? The time stored in the database is the servers time. ...

Get the next xx:30 time (the next half-past hour) after a specified time

I'm trying to find a MySQL query which will obtain the time that is the next half-past-the-hour from a specified datetime. I explicitly mean the next half-past-the-hour, not the next half-hourly point. So for instance: If the datetime was "2009-10-27 08:15:24", the answer would be "2009-10-27 08:30:00" If the datetime was "2009-10-27 ...

Binding to a Nullable<DateTime> control property

We have a custom control that has a "Value" property of type System.Nullable (aka System.DateTime?). We have an object with a "Received" property of the same type. When we try to bind the control to the object, the following InvalidCastException is thrown: Invalid cast from 'System.DateTime' to 'System.Nullable`1[[System.DateTime, msc...

Ruby Time Calculations

I am trying to determine the duration of elapsed time minus any interruptions. The method below seems inefficient and silly is there a better method? The user specifies an end_time and a start_time are and records any interruptions as an integer representing minutes. def duration ((end_time - start_time).seconds - interrupt.minutes) ...

How can I sum data over five minute time intervals in Perl?

I have a file in below format. DATE Time, v1,v2,v3 05:33:25,n1,n2,n3 05:34:25,n4,n5,n5 05:35:24,n6,n7,n8 and so on upto 05:42:25. I want calculate the values v1, v2 and v3 for every 5 min interval. I have written the below sample code. while (<STDIN>) { my ($dateTime, $v1, $v2, $v3) = split /,/, $_; my ($date, $time) = split ...

Datastore datetimeproperty iterable?

Hi, I have model class info(db.Model): user = db.UserProperty() last_update_date = db.DateTimeProperty() I need to retrieve last_update_date for specific user. It is working good, i can retrieve this value, i can even pass it to another variable if results: for result in results: data = result.last_up...

Is there any way to use a strftime-like function for dates before 1900 in Python?

I didn't realize this, but apparently Python's strftime function doesn't support dates before 1900: >>> from datetime import datetime >>> d = datetime(1899, 1, 1) >>> d.strftime('%Y-%m-%d') Traceback (most recent call last): File "<stdin>", line 1, in <module> ValueError: year=1899 is before 1900; the datetime strftime() methods requi...

MySQL datetime fields and daylight savings time -- how do I reference the "extra" hour?

I'm using the America/New York timezone. In the Fall we "fall back" an hour -- effectively "gaining" one hour at 2am. At the transition point the following happens: it's 01:59:00 -04:00 then 1 minute later it becomes: 01:00:00 -05:00 So if you simply say "1:30am" it's ambiguous as to whether or not you're referring to the first tim...

Why does DateTime::Format::W3CDTF return 0 for Europe/London dates outside of British Summer Time?

Ever since British Summer Time ended in the UK last week my application has been seeing a very interesting bug. Here's an isolated Perl script which demonstrates the issue: #!/usr/bin/perl use strict; use warnings; use DateTime::Format::W3CDTF; use DateTime::Format::ISO8601; my $tz = 'Europe/London'; sub print_formatted_date { my ...

Javascript Date and JSON DateTime

I have a problem with Jquery function getJSON, the action url does not trigger because one of the parameter i am passing is a javascript date but the action expects c# DateTime.. Is it possible to format the Javascript Date to make it compatible for c# DateTime? ...

How to show DateField with AM/PM format in blackberry?

I don't know how to show Time in AM/PM format in blackberry using blackberry datefield.Pls give me a idea how to do this. ...

Breakdown of time spans between a list of Datetime's

Hello, I have a SQL Server 2005 database table, which has a datetime column. I write an entry in this table every time a service processes an incoming request. What I would like to get is a breakdown of the time spans between sequential entries. If the data is: 2009-10-30 04:06:57.117 2009-10-30 03:52:44.383 2009-10-30 03:42:00.990 2...

Generating a dynamic time delta: python

Hello all. Heres my situation: import foo, bar, etc frequency = ["hours","days","weeks"] class geoProcessClass(): def __init__(self,geoTaskHandler,startDate,frequency,frequencyMultiple=1,*args): self.interval = self.__determineTimeDelta(frequency,frequencyMultiple) def __determineTimeDelta(self,frequency,frequencyMu...

C++ standard date/time class

Does C++ stl have a standard time class? Or do I have to convert to c-string before writing to a stream. Example, I want to output the current date/time to a string stream: time_t tm(); ostringstream sout; sout << tm << ends; In this case I get the current date/time written out as a number without any formatting. I can use c- runtime...

AJAX control toolkit CalendarExtender date format

I expect it to be Thread.CurrentThread.CurrentUICulture.DateTimeFormat.ShortDatePattern if not specified explicitly in CalendarExtender.Format property but it's not. I don't set the property in my .aspx markup but in the debugger it reports "d". Well, DateTime.Now.ToString("d") returns "31.10.2009" (which corresponds to CurrentUICulture)...

In ASP.NET, how can I force the format of dates in a DropDownList to "DD/MM/YYYY"?

I have to build a DropDownList with the dates of the last 7 days. I would like the DropDownList displays the date as "DD/MM/YYYY". So I created a list of dates: DateTime date = DateTime.Now; List<DateTime> dates = new List<DateTime>(); for (int i = 0; i < HISTORY_LENGTH; i++) { dates.Add(date.AddDays(-i)); } DropDownList.DataSourc...

Why is DateTime a structure in .Net?

Why is DateTime a structure instead of an inheritable class? (I would like to be able to override the ToString() method but I can't.) ...

SQL Query - Ensure data in a table covers a year, with no date overlaps

I have a table called tblRentalRates with the following columns: rate_id (int) rate_startdate (datetime) rate_enddate (datetime) weekday_rate (money) weekend_rate (money) I want to accomplish the following goal: Write a query that will check the contents of the table and ensure that for the current year, that the data covers ...