datetime

SQL: How to Group by Custom Year

For simplicities sake, I'll make up a similar example to what I have: Let's say a db has a table of orders with an OrderDate field and a Company field. Then there's a table of Companies and each record has a YearEndingDate (which signifies that the year ends on that date each year, e.g. 6/6). I need to add up all of the orders for eac...

How do I nicely display relative time using VB.NET?

I want to display a "date/time submitted" value much the same way as Stack Overflow does e.g.* 2 hours ago * 3 days ago * a month ago I see extensive answers on how to do this in PHP but can someone help me with the VB version? ...

Weird flex date issue

Flex is driving me CRAZY and I think it's some weird gotcha with how it handles leap years and none leap years. So here's my example. I have the below dateDiff method that finds the number of days or milliseconds between two dates. If I run the following three statements I get some weird issues. dateDiff("date", new Date(2010, 0,1)...

Fuzzy Date algorithm in Objective-C

I would like to write a fuzzy date method for calculating dates in Objective-C for iPhone. There is a popular explanation here: http://stackoverflow.com/questions/11/how-do-i-calculate-relative-time However it contains missing arguments. How could this be used in Objective-C?. Thanks. const int SECOND = 1; const int MINUTE = 60 * SEC...

When is the best time to call a function to change data being returned from the database

I have two functions written in VB.NET: 1) The first function (call it GetValues()) returns values in a SQL database as a list via a stored proc. One of the fields is DateTimeSubmitted. All of this data is displayed on my webpage using a repeater control. It works fine. 2) The second function (call it NiceDate()) I created to change t...

Formatting a date in javascript

I noticed that javascript new Date() function is very smart in accepting dates in several formats. Xmas95 = new Date("25 Dec, 1995 23:15:00") Xmas95 = new Date("2009 06 12,12:52:39") Xmas95 = new Date("20 09 2006,12:52:39") But i could not find documentation anywhere showing what all string formats that are valid while calling new Date(...

Python, Django, datetime

In my model, I have 2 datetime properties: start_date end_date I would like to count the end date as a one week after the start_date. How can I accomplish this? ...

Does SQL Server 2005 Automatically Convert Time Fields to UTC? Does ADO.Net?

I'm using Visual Studio 2008. I'm using an .xsd/tableadapters to access a SQL Server 2005 database. One of my tables has a DateTime field. When a record is inserted into the table, the time is automatically converted to the UTC time, which is fine. I just want to know where that takes place. Does SQL Server do the conversion or is .Net d...

Does DateTime.ToString("s") return always same format?

According to MSDN on DateTime.ToString ToString("s") should always return string in the format of the sortable XML Schema style formatting, e.g.: 2008-10-01T17:04:32.0000000 In Reflector I came to this pattern inside DateTimeFormatInfo. public string SortableDateTimePattern { get { return "yyyy'-'MM'-'dd'T'HH'...

Mysql Compare two datetime fields

Hi All, I want to compare two dates with time, I want all the results from tbl where date1 > date2 Select * From temp where mydate > '2009-06-29 04:00:44'; but it is just comparing dates not time. it is giving me all the result set of today's date '2009-06-29 11:08:57' '2009-06-29 11:14:35' '2009-06-29 11:12:38' '2009-06-29 11:37:48...

C# Convert strings to DateTime

I have 2 strings: string d = "09/06/24"; string t = "13:35:01"; I want to take the strings and combine them to make a datetime variable: newDT = Convert.ToDateTime(d + t); Compiles but when it hits that line it fails..........any ideas? ...

Adding a number of days to a JodaTime Instant

I'm trying to write a simple utility method for adding aninteger number of days to a Joda time instant. Here is my first stab. /** * Adds a number of days specified to the instant in time specified. * * @param instant - the date to be added to * @param numberOfDaysToAdd - the number of days to be added to the instant specified * @r...

Parse month and date from string DateTime

Lets say you have strings of this format. January 11th, "111" November 1st, "1101" October 13th, "1013" etc. So basically all you want to parse it and store in two variables date and month. I do not need code for parsing, I can easily do that. I was just wondering if someone knows the way to do it using something like DateTime.TryPars...

A better CDate for VB6

We have a a VB6 app (in a COM component) which uses CDate() to take a string and cast it to a Date, for storing in a database. Depending on if we want the application to talk in dd/MM/yy or MM/dd/yy for example, we have to change the regional settings of the identity user for the COM application. (Right now the only option we have is a...

Iterating through a range of dates in Python

This is working fine, but I'm looking for any feedback on how to do it better. Right now I think it's better than nested loops, but it starts to get Perl-one-linerish when you have a generator in a list comprehension. Any suggestions are welcome. day_count = (end_date - start_date).days + 1 for single_date in [d for d in (start_date + t...

Mysql what field type to use for dates with a mix of full and part dates

I have a table that has three different date columns, so I set each column as type 'date'. However whenever im importing dates it seems to change them, and I have found it is because mysql does not allow null days and months. My dates range from 1909-00-00 1963-09-00 1907-11-30 so sometimes we dont know the month, sometimes the day, ...

WPF XAML StringFormat DateTime: Output in wrong culture?

I'm having some trouble with the output of a DateTime value. My computer's current culture is set to de-AT (Austria). The following code string s1 = DateTime.Now.ToString("d"); string s2 = string.Format("{0:d}", DateTime.Now); results in s1 and s2 both having the correct value of "30.06.2009". But when using the same format in XAML ...

Date parsing with regular expressions in JavaScript

I'm using match() in JavaScript to parse a dates from an RSS feed, I just can't get my head around the correct regular expression to find the date format. Here's the date: 2009-05-11 16:59:20 And the regular expression so far: if (dateToParse.match(/^\d\d\d\d-\d\d-\d\d/)) { dateTimeSeparator = " "; monthIndex = 0; ...

Transform a date using a regular expression from 24Dec to 24/12 or 24/12/2009

I get travel confirmations that look like this: "SQ 966 E 27JUL SINCGK" = "Airline Space Flight Space BookingClass Space Date_with_Month_as_name Space 3LetterFrom 2LetterTo". I can chop all this into pieces using a regex to submit it to a website. But the site would expect instead of 27JUL 27/07/2009 or at least 27/07. Is there a way t...

NHibernate:HQL: Remove time part from date field

I'm trying to group table values by date, and this HQL query works fine: SELECT af.SubmitedDate, COUNT (af.Id) FROM ApplicationForm af GROUP BY af.SubmitedDate The problem is that field af.SubmitedDate also contains time part, sine I'm using SQL Server 2005, so the grouping is done by date-time, not only by date. When I try to d...