date-comparison

Getting date list in a range in PostgreSQL

回眸只為那壹抹淺笑 提交于 2019-11-26 22:18:19
I'd like to get the list of days between the two dates (including them) in a PostgreSQL database . For example, if I had: start date: 29 june 2012 end date: 3 july 2012 then the result should be: 29 june 2012 30 june 2012 1 july 2012 2 july 2012 3 july 2012 What would be the best way of doing this in PostgreSQL? Thanks. select CURRENT_DATE + i from generate_series(date '2012-06-29'- CURRENT_DATE, date '2012-07-03' - CURRENT_DATE ) i or even shorter: select i::date from generate_series('2012-06-29', '2012-07-03', '1 day'::interval) i As timestamp : select generate_series('2012-06-29', '2012-07

How to compare two dates in Objective-C

别说谁变了你拦得住时间么 提交于 2019-11-26 11:10:35
I have two dates: 2009-05-11 and the current date. I want to check whether the given date is the current date or not. How is this possible. Cocoa has couple of methods for this : in NSDate – isEqualToDate: – earlierDate: – laterDate: – compare: When you use - (NSComparisonResult)compare:(NSDate *)anotherDate ,you get back one of these: The receiver and anotherDate are exactly equal to each other, NSOrderedSame The receiver is later in time than anotherDate, NSOrderedDescending The receiver is earlier in time than anotherDate, NSOrderedAscending. example: NSDate * now = [NSDate date]; NSDate *

Get most recent date from an array of dates

若如初见. 提交于 2019-11-26 08:25:32
问题 I have the array of dates below array(5) { [0]=> string(19) \"2012-06-11 08:30:49\" [1]=> string(19) \"2012-06-07 08:03:54\" [2]=> string(19) \"2012-05-26 23:04:04\" [3]=> string(19) \"2012-05-27 08:30:00\" [4]=> string(19) \"2012-06-08 08:30:55\" } and would like to know the most recent date as in: the closest to today\'s date. How can I do that? 回答1: Do a loop, convert the values to date, and store the most recent, in a var. $mostRecent= 0; foreach($dates as $date){ $curDate = strtotime(

Getting date list in a range in PostgreSQL

 ̄綄美尐妖づ 提交于 2019-11-26 08:14:22
问题 I\'d like to get the list of days between the two dates (including them) in a PostgreSQL database . For example, if I had: start date: 29 june 2012 end date: 3 july 2012 then the result should be: 29 june 2012 30 june 2012 1 july 2012 2 july 2012 3 july 2012 What would be the best way of doing this in PostgreSQL? Thanks. 回答1: select CURRENT_DATE + i from generate_series(date '2012-06-29'- CURRENT_DATE, date '2012-07-03' - CURRENT_DATE ) i or even shorter: select i::date from generate_series(

How to compare two dates in Objective-C

那年仲夏 提交于 2019-11-26 02:17:47
问题 I have two dates: 2009-05-11 and the current date. I want to check whether the given date is the current date or not. How is this possible. 回答1: Cocoa has couple of methods for this: in NSDate – isEqualToDate: – earlierDate: – laterDate: – compare: When you use - (NSComparisonResult)compare:(NSDate *)anotherDate ,you get back one of these: The receiver and anotherDate are exactly equal to each other, NSOrderedSame The receiver is later in time than anotherDate, NSOrderedDescending The