|
I have fairly long and complex SQL query that is run against PostgreSQL 8.3. Part of the query involves filtering on a range of dates ending with today, like this:
where ... and sp1.price_date between current_date::date - '1 year'::interval and current...
Started by Evgeny on
, 4 posts
by 4 people.
Answer Snippets (Read the full thread at stackoverflow):
I assume you want to cast to date instead: (current_date - '2 weeks'::interval)::date
EDIT: the following was tested but it ran is incurred by all the....
Current__date - '...'::interval would return a timestamp w/o timezone.
|
|
I have an object that has a start date and an end date, in order to represent the time that the object is valid. Given a date, is there a way to only select those objects that have valid ranges that contain the date?
I tried fiddling with between, but...
Started by Joan Smith on
, 4 posts
by 4 people.
Answer Snippets (Read the full thread at stackoverflow):
Foo.find(:all, :conditions => ['valid_from....
Select * from table where start_date <= given_date and end_date >= given_date
This is how you'd do it using active record.
If you were doing this for "given_date".
|
|
I'd like to use Zend_Date to print out the previous 2 months and year as a string e.g.:
July 2009 June 2009
I need it to be locale aware so that if the code runs with the locale set to, say, German, the month names will print in German.
$date = new Zend...
Started by codecowboy on
, 3 posts
by 3 people.
Answer Snippets (Read the full thread at stackoverflow):
Like this:
$date = new Zend_Date(new Zend_Locale('de_AT')); $date->subMonth(1); echo $date->get(Zend_date::MONTH_NAME).' '.$date->get(Zend....
Specify the locale when creating the Zend_Date object.
|
Ask your Facebook Friends
|
I'd like to find the date after a date provided by the user
This is not working:
$start_date = '2009-06-10'; $next_day = date( $start_date, strtotime('+1 day') ); echo $next_day; // 2009-06-10
Started by htxt on
, 4 posts
by 4 people.
Answer Snippets (Read the full thread at stackoverflow):
$start_date = '2009-06-10'; $next_day = date( 'Y....
Try date_modify:
$d = new DateTime("2009-01-01"); date_modify($d, "+1 day"); echo $d->format("Y-m-d");
Documentation at http://us3.php.net/manual/en/datetime.modify.php .
|
|
I have a list of Date objects, and a target Date. I want to find the date in the list that's nearest to the target date, but only dates that are before the target date.
Example: 2008-10-1 2008-10-2 2008-10-4
With a target date of 2008-10-3, I want to ...
Started by Sietse on
, 6 posts
by 6 people.
Answer Snippets (Read the full thread at stackoverflow):
Private Date getDateNearest(List<Date> dates, Date targetDate){ for (Date date : dates) { if (date....
This assumes an already sorted list, and (potentially) iterates over every single date in the list.
|
|
How to set date to current date using dos batch file command.
Started by silverkid on
, 4 posts
by 4 people.
Answer Snippets (Read the full thread at stackoverflow):
If you need to use the current date in a batch file....
This works on my Windows XP box:
date 15-02-2010, the day and month fields gets flipped if the date is written in that format.
The date command is what you are looking for.
|
|
I'm trying to use javascript to convert a date object into a valid mysql date - what is the best way to do this?
Started by BrynJ on
, 3 posts
by 3 people.
Answer Snippets (Read the full thread at stackoverflow):
But to do it manually, you can use Date#getFullYear() , Date#getMonth() (it starts with 0 = January, so you probably want + 1), and Date#getDate() (day = Date_toYMD; function ....
Probably best to use a library like Date.js.
|
|
How can I check if date is between two dates in java (Not through a MySQL query)?
Started by Gnaniyar Zubair on
, 7 posts
by 7 people.
Answer Snippets (Read the full thread at stackoverflow):
Like so:
Date min, max; // assume these are set to something Date d; // the date in question return readable:
Date min, max; // assume these are set to something Date d; // the date in question return want to ....
|
|
How to display a date as 2/25/2007 format in javascript, if i have date object
Started by Sunny Mate on
, 5 posts
by 5 people.
Answer Snippets (Read the full thread at stackoverflow):
() + 1) + "/" + date.getDay() + "/" + date.getFullYear();
function formatDate(a) //pass date object(dte){ return ( ((dte) && (typeof(dte.format)=="function")) ? dte.format("MM/dd/yyyy") : "Not a Date Object" ); }
ASP.net AJAX has a format....
|
|
I'd like to get an 'end date' from a given 'start date' in PHP . End date is based off the start and are calculated as follows:
If Start date is from the 1-15th of the month, End date is the 15th of the following month.
If Start date is from the 16-31...
Started by Mithun on
, 3 posts
by 3 people.
Answer Snippets (Read the full thread at stackoverflow):
* (1-floor($d1['mday']/16)), //15 before the 16th, then 0 $d1['year'] ); $end_date = date('Y-m-d', $end_timestamp);
Here's another way to do it:
$dt = new DateTime($start_date); if ($dt->format.
|