datetime

How to get a time since string from a NSDate object?

Basically, I'm getting a date time string from an API, and I want to show in the app that this activity happened '5 hours ago' or '3 days ago', and so on... I am currently trying to get the NSTimeInterval from [NSDate timeIntervalSinceNow] method. And then converting the time interval to NSDate again using [NSDate dateWithTimeIntervalSi...

Comparing future dates in C#

I know this is probably a pretty simple question, but i am trying to write a function that returns a bool value of "true" if a date passed is in the future, like this: bool IsFutureDate(System.DateTime refDate) { if (refDate > DateTime.Now) // This doesn't seem to work return true; return false; } Anyone tell me who t...

How do I represent a time only value in .NET?

Is there is way in which one can represent a time only value in .NET without the date? For example, indicating the opening time of a shop? TimeSpan indicates a range, whereas I only want to store a time value. Using DateTime to indicate this would result in new DateTime(1,1,1,8,30,0) which is not really desirable. ...

Sorting datetime objects while ignoring the year?

I have a list of birthdays stored in datetime objects. How would one go about sorting these in Python using only the month and day arguments? For example, [ datetime.datetime(1983, 1, 1, 0, 0) datetime.datetime(1996, 1, 13, 0 ,0) datetime.datetime(1976, 2, 6, 0, 0) ... ] Thanks! :) ...

a fundamental question on system date

Please forgive my naivette...a very fundamental question: I have a google app engine project that has a cron job that fetches records with date matching the current system date. This cron job triggers at 0:00 (ie, 12:00AM midnight) everyday. The cron job is apparently fetching records corresponding to the previous day. What could be wro...

DateTimeProperty has error being set to a datetime in Google App Engine

I'm having a weird error with some Google App Engine code I'm writing. My program contains some code like this: import datetime ... class Action(db.Model): visibleDate = db.DateTimeProperty() ... getActionQuery = Action.gql("WHERE user = :user AND __key__ = :key", user = user, key = self.request.get("key")) theAction = getActio...

Regex needed for parsing a date/time string

Can someone provide me with a regex for the following? (Using Javascript) source string: Jan 2 2010 6:00PM I want the resulting string to show only the time, as shown below. (example above used) result string: 6:00 PM ...

SQL Server 2005, Replicating between timezones.

How does SQL Server handle the transfer of the datetime columns when replicating between timezones? ...

SQLite query to join on a range of dates?

I am working with SQLite. Suppose I have a table sales with two columns, date and count, to keep track of how many glasses of lemonade I sold on that date. If I don't sell any lemonade on a given day, I am too depressed to create a new row in the sales table. I'd like to find out the average number of glasses sold over a given date ran...

MYSQL - Retrieve Timestamps between dates

All, I have a MYSQL table with a column called timestamp. It is of DATETIME datatype and has values like "10/1/2009 3:25:08 PM', "10/1/2009 3:30:05 PM', "10/4/2009 3:40:01 PM', etc.. I want to write a SQL query to select all the values in the timestamp field occuring between two dates.. something like this: select timestamp from table...

vb .net null condition

this is my code - Dim provider As CultureInfo = CultureInfo.InvariantCulture Dim a1 As DateTime = Nothing insexp = DateTime.ParseExact(date1.SelectedValue, "MMMM yyyy", provider) If a1.Month = Today.Month AndAlso a1.Year = Today.Year Then a1 = Today.Date End If ...

C# : Why is my SqlDateTime.MinValue different on different machines?

I just found that my SqlDateTime.MinValue is different on different machines. Sometimes it is = DateTime(1953, 1, 1, 0, 0, 0); but on other machines it is = DateTime(1753, 1, 1, 0, 0, 0); How can that be? OS on both machines is WinXP SP2. Edit: My code was like this: DateTime date; ... if (date == SqlDateTime.MinValue) { retu...

No Default Date in SWT DateTime ...

I'm using a SWT DateTime component. It sets the current date as a default selection, when instanciated. How can i prevent this? I want that no date is selected at all... Thanks Patrick ...

Reformat php date compare function

Hi again fellas! Found the following snippet online and are currently using it in my web application, however it returns time like "0:5:1". I would like it to format the output like a real date, ie: 00:05:01. Guess that there is an embarrassing quick solution to solve this. Here comes the snippet: function getTimeDifference($start, $e...

Query on datetime fields with milliseconds gives wrong result in SQL Server

I'm running into an odd bug using datetime fields in SQL Server 2005. The datetime field shows up with millisecond-level accuracy, but it looks like the milliseconds are not always used. Here's my test query: SELECT col1, YEAR(col1) AS yr, MONTH(col1) AS mn, DAY(col1) AS dy FROM mytable WHERE col1 >= '2009-12-31 00:00:00.0' AND col1 <= ...

PHP date issue - strtotime does not output what it's supposed to?

Hi! I have a couple of blanks DATETIME values(0000-00-00 00:00:00) in my database. Whenever i run those through strtotime, they return "1263247058" instead of FALSE, which it should do according to the info on the linked page: http://stackoverflow.com/questions/1224680/php-strtotime-outputs-nothing How come? Thanks. ...

NHibernate filter criteria - Hour of DateTime

I am having hard times convincing NHibernate (EF was able to do it) to filter based on the Hour property of a DateTime entity property. My entity goes something like : public class Invoice { // ... public DateTime Time { get; set; } // ... } I need to retrieve all the invoices that were "made" at a certain hour (let's say ...

iPhone simple method definition and calling the current date/time

I'm very new to iPhone development, and I'm trying to write a function which will accept one parameter, and return the current date/month and store it in a variable. But I'm getting a (null) value with NSLog. Method: -(NSString *) getNowDateMonth:(NSString *)type { NSDate *now = [[NSDate alloc] init]; if (type==@"month") { ...

Storing current time as integer

Hi, I would like to store the current time as an integer, re perl. I know I need a TimeSpan, starting from windows time start. I know windows time starts from when?, Jan 1st, 1601. scope_creep ...

.net dropdownlist if condition

I had posted this question before but didnt get the right answer - here's my code again with the if condition. Dim provider As CultureInfo = CultureInfo.InvariantCulture Dim a1 As DateTime = Nothing if date1.selectedvalue isnot nothing then insexp = DateTime.ParseExact(date1.SelectedValue, "MMMM yyyy", provider...