date
Get the last day of the month
calendar.monthrange provides this information: calendar.monthrange(year, month) Returns weekday of first day of the month and number of days in month, for the specified year and month. >>> import calendar >>> calendar.monthrange(2002, 1) (1, 31) >>> calendar.monthrange(2008, 2) # leap years are handled correctly (4, 29) >>> calendar.monthrange(2100, 2) # years divisible by 100 but not … Read more
Why is subtracting these two epoch-milli Times (in year 1927) giving a strange result?
It’s a time zone change on December 31st in Shanghai. See this page for details of 1927 in Shanghai. Basically at midnight at the end of 1927, the clocks went back 5 minutes and 52 seconds. So “1927-12-31 23:54:08” actually happened twice, and it looks like Java is parsing it as the later possible instant … Read more
How to subtract n days from current date in java? [duplicate]
You don’t have to use Calendar. You can just play with timestamps : Date d = initDate();//intialize your date to any date Date dateBefore = new Date(d.getTime() – n * 24 * 3600 * 1000 l ); //Subtract n days UPDATE DO NOT FORGET TO ADD “l” for long by the end of 1000. Please … Read more
Adding Days to a Date but Excluding Weekends
using Fluent DateTime https://github.com/FluentDateTime/FluentDateTime var dateTime = DateTime.Now.AddBusinessDays(4);
Get date for monday and friday for the current week (PHP)
Best solution would be: $monday = date( ‘Y-m-d’, strtotime( ‘monday this week’ ) ); $friday = date( ‘Y-m-d’, strtotime( ‘friday this week’ ) );
SQL query for getting data for last 3 months
SELECT * FROM TABLE_NAME WHERE Date_Column >= DATEADD(MONTH, -3, GETDATE()) Mureinik’s suggested method will return the same results, but doing it this way your query can benefit from any indexes on Date_Column. or you can check against last 90 days. SELECT * FROM TABLE_NAME WHERE Date_Column >= DATEADD(DAY, -90, GETDATE())
ORA-01830: date format picture ends before converting entire input string / Select sum where date query
I think you should not rely on the implicit conversion. It is a bad practice. Instead you should try like this: datenum >= to_date(’11/26/2013′,’mm/dd/yyyy’) or like datenum >= date ‘2013-09-01’
php weeks between 2 dates
Here’s an alternative solution using DateTime:- function datediffInWeeks($date1, $date2) { if($date1 > $date2) return datediffInWeeks($date2, $date1); $first = DateTime::createFromFormat(‘m/d/Y’, $date1); $second = DateTime::createFromFormat(‘m/d/Y’, $date2); return floor($first->diff($second)->days/7); } var_dump(datediffInWeeks(‘1/2/2013’, ‘6/4/2013’));// 21 See it working