dates

Calculate the year for ending month/day?

Given: Start Year Start Month & Start Day End Month & End Day What SQL statement results in TRUE if a date lands between the Start and End days? The problem is in finding the end year so as to get a start_date and an end_date. ...

I need data structure for effective handling with dates

What I need is something like Hashtable which I will fill with prices that were actual at desired days. For example: I will put two prices: January 1st: 100USD, March 5th: 89USD. If I search my hashtable for price: hashtable.get(February 14th) I need it to give me back actual price which was entered at Jan. 1st because this is the ...

Compare Dates DataAnnotations Validation asp.net mvc

Lets say I have a StartDate and an EndDate and I wnt to check if the EndDate is not more then 3 months apart from the Start Date public class DateCompare : ValidationAttribute { public String StartDate { get; set; } public String EndDate { get; set; } //Constructor to take in the property names that are supposed to be che...

Subtract dates in Ruby and get the difference in minutes

Hi, how do i subtract two different UTC dates in Ruby and then get the difference in minutes? Thanks ...

C# Error reading two dates from a binary file

Hi all, When reading two dates from a binary file I'm seeing the error below: "The output char buffer is too small to contain the decoded characters, encoding 'Unicode (UTF-8)' fallback 'System.Text.DecoderReplacementFallback'. Parameter name: chars" My code is below: static DateTime[] ReadDates() { System.IO.FileStream ap...

C# Number of days between two dates problem

Hi all, I have a small problem with the code below, the 'days' variable always seems to be 0 no matter how far apart the days are. Can you see anything obviously wrong? System.TimeSpan span = dates[0] - dates[1]; // e.g. 12/04/2010 11:44:08 and 18/05/2010 11:52:19 int days = (int)span.TotalDays; if (days > 10...

Sort file as Month name in ColdFusion

I have a directory, it contains files like: january2009.xml, february2009.xml, march2009.xml,april2009.xml,january2010.xml, february2010.xml, march2010.xml,april2010.xml ... I use the cfdirectory to get the file by year. Right now, I want to display it as sorted order in month. Say If I only want year 2009 data. I want it sorted as j...

How can I loop through each of the days of a given week in Ruby?

I am defining monday and friday using the following: @monday = Date.today.at_beginning_of_week @friday = 5.days.since(@monday) But I actually need, for any given day, to loop through Monday, Tuesday, Wednesday and take that date and put the output into a column. <th>Monday</th> <th>Tuesday</th> etcetera A given row, for example, ...

Oracle TIMESTAMP w/ timezone data type confusion

When would you use TIMESTAMP w/ timezone as opposed to TIMESTAMP w/ local time zone? When data is stored in a column of data type TIMESTAMP w/ local tz, the data is normalized to the database time zone, and the time zone displacement is not stored as part of the column data. When users retrieve the data, Oracle returns it in the users'...

How do I find all the datetimes that happen on a particular date in ruby?

I have a method which goes through each day of the week: def dates_week(d, delim) "<tr>" + (d.beginning_of_week...(d.beginning_of_week+5)).map do |day| "<#{delim}> #{yield(day)} </#{delim}>" end.join + "</tr>" end For each day of the week, I plug that as an arg into a method (or maybe a named_scope, haven't figure...

Sharepoint - End date minus Start date = Years??

Hi, I am needing to calculate the number of years between two fields; Field A Start Date (dd/mm/yyyy) Field B End Date (dd/mm/yyyy) Field C Calc formula display difference between Field A and B in years and months i.e 5.2 Thanks all. ...

Optimize date query for large child tables: GiST or GIN?

Problem 72 child tables, each having a year index and a station index, are defined as follows: CREATE TABLE climate.measurement_12_013 ( -- Inherited from table climate.measurement_12_013: id bigint NOT NULL DEFAULT nextval('climate.measurement_id_seq'::regclass), -- Inherited from table climate.measurement_12_013: station_id integer...

PHP / Zend custom date input formats

Hi, I'm creating a library component for other developers on my team using PHP and Zend. This component needs to be able to take as input a date (string) and another string telling it the format of that date. Looking through the Zend documentation and examples, I thought I found the solution - $dateObject = Zend_Date('13.04.2006', ar...

Algorithm: how to check intersections of recurring events definitions?

The question comes from MS Outlook calendar behavior. Imagine I have two recurring events (starting from today): "each second Monday" and "every odd date". Is there any way to check intersections and/or find the first intersecting date algorithmically without brute-forcing over each date? Definitions can be made in CRON's notations or...

Detect last week of each month with javascript

Hi, what would be a way in javascript to detect the last week of each (current) month. Or last monday of the month? ...

Implementation code for GetDateFormat Win32 function

I am porting some legacy code from windows to Linux (Ubuntu Karmic to be precise). I have come across a Win32 function GetDateFormat(). The statements I need to port over are called like this: GetDateFormat(LOCALE_USER_DEFAULT, 0, &datetime, "MMMM", 'January', 31); OR GetDateFormat(LOCALE_USER_DEFAULT, 0, &datetime, "MMMM", 'May', 3...

PHP Time Zone Adjustment

I have a time that is being sent to me in UTC time, but I want to adjust it so its the outer edges of the days on East Coast time (EST/EDT). That is, I want the user to be able to enter in EDT/EST centric dates, and have it query with the UTC correct dates. $start_date and $end_date are MM/DD/YYYY formatted dates passed via a GET varia...

Calculate year for end date: PostgreSQL

Background Users can pick dates as shown in the following screen shot: Any starting month/day and ending month/day combinations are valid, such as: Mar 22 to Jun 22 Dec 1 to Feb 28 The second combination is difficult (I call it the "tricky date scenario") because the year for the ending month/day should come after the year for th...

SQL (server) date conversion

I want to convert the run duration (from msdb..sysjobhistory) to an elapsed seconds figure. The duration is stored as an integer where for example 13 means 13 secs 213 means 2 mins and 13 secs = 133 secs 310213 means 31 hours, 2 mins and 13 secs = 111,733 secs Is there any neat way of doing this? It's SQL Server 2000 but I wo...

Check for repeating dates.

I am creating a calendar in PHP and in the database have a date, let's say 6-10-10. Sometimes I have repeating events, stored as weekly repeating, so if the date is 6-10-10, and I am repeating an event every two weeks from that day (including that day) what is the best way to find dates for every two weeks from 6-10-10? For example, le...