weekend

Determine if Oracle date is on a weekend?

社会主义新天地 提交于 2019-11-26 18:14:05
问题 Is this the best way to determine if an Oracle date is on a weekend? select * from mytable where TO_CHAR (my_date, 'DY', 'NLS_DATE_LANGUAGE=ENGLISH') IN ('SAT', 'SUN'); 回答1: As of Oracle 11g, yes. The only viable region agnostic alternative that I've seen is as follows: SELECT * FROM mytable WHERE MOD(TO_CHAR(my_date, 'J'), 7) + 1 IN (6, 7); 回答2: Not an answer to the question . But some more information. There are many more SQL tricks with date. to_char(sysdate, 'd') --- day of a week, 1,2,3

How do I exclude Weekend days in a SQL Server query?

风流意气都作罢 提交于 2019-11-26 17:25:49
How do I exclude values in a DateTime column that are Saturdays or Sundays? For example, given the following data: date_created '2009-11-26 09:00:00' -- Thursday '2009-11-27 09:00:00' -- Friday '2009-11-28 09:00:00' -- Saturday '2009-11-29 09:00:00' -- Sunday '2009-11-30 09:00:00' -- Monday this is the result I'm looking for: date_created '2009-11-26 09:00:00' -- Thursday '2009-11-27 09:00:00' -- Friday '2009-11-30 09:00:00' -- Monday Thanks! When dealing with day-of-week calculations, it's important to take account of the current DATEFIRST settings. This query will always correctly exclude

In Java, get all weekend dates in a given month

谁说我不能喝 提交于 2019-11-26 09:12:44
问题 I need to find all the weekend dates for a given month and a given year. Eg: For 01(month), 2010(year), the output should be : 2,3,9,10,16,17,23,24,30,31, all weekend dates. 回答1: Here is a rough version with comments describing the steps: // create a Calendar for the 1st of the required month int year = 2010; int month = Calendar.JANUARY; Calendar cal = new GregorianCalendar(year, month, 1); do { // get the day of the week for the current day int day = cal.get(Calendar.DAY_OF_WEEK); // check

How do I exclude Weekend days in a SQL Server query?

天大地大妈咪最大 提交于 2019-11-26 08:59:44
问题 How do I exclude values in a DateTime column that are Saturdays or Sundays? For example, given the following data: date_created \'2009-11-26 09:00:00\' -- Thursday \'2009-11-27 09:00:00\' -- Friday \'2009-11-28 09:00:00\' -- Saturday \'2009-11-29 09:00:00\' -- Sunday \'2009-11-30 09:00:00\' -- Monday this is the result I\'m looking for: date_created \'2009-11-26 09:00:00\' -- Thursday \'2009-11-27 09:00:00\' -- Friday \'2009-11-30 09:00:00\' -- Monday Thanks! 回答1: When dealing with day-of

Count days between two dates, excluding weekends (MySQL only)

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-26 08:36:06
问题 I need to calculate the difference (in days) between two dates in MySQL excluding weekends (Saturday and Sunday). That is, the difference in days minus the number of Saturday and Sunday in between. At the moment, I simply count the days using: SELECT DATEDIFF(\'2012-03-18\', \'2012-03-01\') This return 17 , but I want to exclude weekends, so I want 12 (because the 3rd and 4th, 10th and 11th and 17th are weekends days). I do not know where to start. I know about the WEEKDAY() function and all