date-arithmetic

Oracle SQL Where clause to find date records older than 30 days

喜欢而已 提交于 2020-11-25 07:51:05
问题 I want to find records in a (Oracle SQL) table using the creation date field where records are older than 30 days. It would be nice to find records using a operators like > but if anyone can suggest quick SQL where clause statement to find records older than 30 days that would be nice. Please suggest Oracle syntax as that is what I am using. 回答1: Use: SELECT * FROM YOUR_TABLE WHERE creation_date <= TRUNC(SYSDATE) - 30 SYSDATE returns the date & time; TRUNC resets the date to being as of

Getting current date in JSTL EL and doing arithmetic on it

核能气质少年 提交于 2020-07-29 09:16:45
问题 Without using scriptlets, what's the correct way for doing date arithmetic in JSP? Here are examples what I'm trying to do: Get current year (YYYY) Subtract current year by one to get previous year (YYYY) Thanks! 回答1: Use <jsp:useBean> to construct new Date. Use JSTL <fmt:formatDate> to get the year out of it. Use EL to substract it. <%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %> <jsp:useBean id="now" class="java.util.Date" /> <fmt:formatDate var="year" value="${now}"

Getting current date in JSTL EL and doing arithmetic on it

ⅰ亾dé卋堺 提交于 2020-07-29 09:14:48
问题 Without using scriptlets, what's the correct way for doing date arithmetic in JSP? Here are examples what I'm trying to do: Get current year (YYYY) Subtract current year by one to get previous year (YYYY) Thanks! 回答1: Use <jsp:useBean> to construct new Date. Use JSTL <fmt:formatDate> to get the year out of it. Use EL to substract it. <%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %> <jsp:useBean id="now" class="java.util.Date" /> <fmt:formatDate var="year" value="${now}"

Why is Date is being returned as type 'double'?

那年仲夏 提交于 2020-07-06 09:24:59
问题 I'm having some trouble working with the as.Date function in R. I have a vector of dates that I'm reading in from a .csv file that are coming in as a factor of integers or as character (depending on how I read in the file, but this doesn't seem to have anything to do with the issue), formatted as %m/%d/%Y . I'm going through the file row by row, pulling out the date field and trying to convert it for use elsewhere using the following code: tmpDtm <- as.Date(as.character(tempDF$myDate), "%m/%d

Getting Last Day of Previous Month in Oracle Function

独自空忆成欢 提交于 2020-01-21 11:16:04
问题 I need a function in Oracle like this. When i giving a parameter a simple date. Then function should getting me last day of the previous month. Example: FunctionName(10.02.2011) Result should be 31.01.2011 FunctionName(21.03.2011) Result should be 28.02.2011 FunctionName(31.07.2011) Result should be 30.06.2011 (Even date is last day of month) How can i do that? By the way, i never use Oracle . 回答1: SELECT LAST_DAY(ADD_MONTHS(yourdate,-1)) 回答2: As an alternative to the other answers here, you

Getting Last Day of Previous Month in Oracle Function

荒凉一梦 提交于 2020-01-21 11:15:06
问题 I need a function in Oracle like this. When i giving a parameter a simple date. Then function should getting me last day of the previous month. Example: FunctionName(10.02.2011) Result should be 31.01.2011 FunctionName(21.03.2011) Result should be 28.02.2011 FunctionName(31.07.2011) Result should be 30.06.2011 (Even date is last day of month) How can i do that? By the way, i never use Oracle . 回答1: SELECT LAST_DAY(ADD_MONTHS(yourdate,-1)) 回答2: As an alternative to the other answers here, you

SQLITE moving average

。_饼干妹妹 提交于 2020-01-17 07:36:48
问题 Trying to get the moving average on a per X months basis using SQLite. Problem is i cannot seem to figure or find anything remotely useful on how to aggregate with a X month(s) lookback period and thus create a moving average. Table CREATE TABLE "nav" ( `id` TEXT, `nav` NUMERIC, `date` TEXT ); Sample data id nav date 1380 15.3 2005-01-09 1380 15.4 2005-01-16 1380 15.5 2005-01-23 1380 15.55 2005-01-30 1380 15.66 2005-02-06 1380 15.45 2005-02-13 1380 15.26 2005-02-20 1380 15.14 2005-02-27 1380

PHP create range of dates

吃可爱长大的小学妹 提交于 2020-01-15 07:14:43
问题 Starting with a date in this format: 2011-05-01 09:00:00 , how can I create an array that contains all office hours (09:00 to 17:00) for all working days of the year (so excluding all Saturday and Sundays). What I want to arrive to is something like this: 2011-05-01 09:00:00 2011-05-01 10:00:00 2011-05-01 11:00:00 2011-05-01 12:00:00 2011-05-01 13:00:00 2011-05-01 14:00:00 2011-05-01 15:00:00 2011-05-01 16:00:00 2011-05-01 17:00:00 //next day, starting at 09:00 and ending at 17:00 2011-05-02

Working with time values greater than 24 hours in R

徘徊边缘 提交于 2020-01-14 14:57:09
问题 I'm trying to perform calculations on time values that are greater than 24 hours. In this short example, I'm trying to calculate someone's sleep duration based on their bedtime and waketime. If bedtime is after midnight, however, the data are entered as time values greater than 24 hours. For example, if someone went to sleep at 2am, their bedtime value is 26:00:00. How can I handle time values greater than 24 hours in R? Here's my short example attempt: library(chron) bedtime <- c("22:37:34",

How to calculate next Friday at 3am?

ぃ、小莉子 提交于 2020-01-13 07:58:06
问题 How can you calculate the following Friday at 3am as a datetime object? Clarification: i.e., the calculated date should always be greater than 7 days away, and less than or equal to 14. 回答1: Here's a function and a test that it meets the OP's requirements: import datetime _3AM = datetime.time(hour=3) _FRI = 4 # Monday=0 for weekday() def next_friday_3am(now): now += datetime.timedelta(days=7) if now.time() < _3AM: now = now.combine(now.date(),_3AM) else: now = now.combine(now.date(),_3AM) +