days

Pandas | 22 时间差

这一生的挚爱 提交于 2019-12-03 15:05:45
时间差(Timedelta)是时间上的差异,以不同的单位来表示。例如:日,小时,分钟,秒。它们可以是正值,也可以是负值。 可以使用各种参数创建 Timedelta 对象,如下所示 - 字符串 通过传递字符串,可以创建一个 timedelta 对象。参考以下示例代码 - import pandas as pd timediff = pd.Timedelta('2 days 2 hours 15 minutes 30 seconds') print(timediff) 输出结果: 2 days 02:15:30 整数 通过传递一个整数值与指定单位,这样的一个参数也可以用来创建 Timedelta 对象。 import pandas as pd timediff = pd.Timedelta(6,unit='h') print(timediff) 输出结果: 0 days 06:00:00 数据偏移 例如 - 周,天,小时,分钟,秒,毫秒,微秒,纳秒的数据偏移也可用于构建。 import pandas as pd timediff = pd.Timedelta(days=2) print(timediff) 输出结果: 2 days 00:00:00 运算操作 可以在Series/DataFrames上执行运算操作,并通过在 datetime64 [ns] 系列或在时间戳上减法操作来构造

sap 日期相关函数

限于喜欢 提交于 2019-12-03 14:22:10
获取输入日期前、后的年、月、日之后的日期: FIMA_DATE_CREATE DATA : date TYPE vtbbewe-dvalut, flag TYPE trff_flg, days TYPE trff_type_n_2. CALL FUNCTION 'FIMA_DATE_CREATE' EXPORTING i_date = '20140101' "输入日期 i_flg_end_of_month = ' ' i_years = 2 "两年后的日期. 即输入日期的年加2所得日期,可为负数,表示前两年 i_months = 1 "一个月后的日期.即输入日期的月加1所得日期,可为负数,表示前一个月 i_days = 23 "23天后的日期。可为负数,表示23天前的日期 i_calendar_days = 10 "10天后的日历。同I_DAYS参数。 i_set_last_day_of_month = 'X' "返回的日期为当前月份的最后一天 IMPORTING e_date = date "返回的日期为当前月份的最后一天 e_flg_end_of_month = flag "如果输入参数I_SET_LAST_DAY_OF_MONTH设置’X’了,则返回值为’X’。 e_days_of_i_date = days. "返回输入日期的i_calendar_days字段与I

Javascript Epoch Time In Days

丶灬走出姿态 提交于 2019-12-03 12:45:00
I need the epoch time in days. I've seen posts on how to translate it to date but none in days. I'm pretty bad with epoch time...how could I get this? RobG I need the epoch time in days I'll interpret that you want the number of days since the epoch. The epoch itself is day zero (or the start of day 1, however you want to view it). At the heart of a javascript Date object is a number of milliseconds since 1970-01-01T00:00:00Z. So to get the number of days from then to now you simply get the current time value and divide it by the number of milliseconds in one day: var now = new Date(); var

calculate days between dates

匿名 (未验证) 提交于 2019-12-03 10:24:21
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm trying to calculate the days between 2 dates but just keep getting "NaN. I've looked at other posts but can't quite work it out :-S function checkdate() { var currentTime = new Date() var month = currentTime.getMonth() + 1 var day = currentTime.getDate() var year = currentTime.getFullYear() var datenow = (day + "/" + month + "/" + year) var startdate = document.forms[0].datescopestart.value; var sDate = new Date(Date.parse("startdate","dd/mm/yy")); var totaldays = Date.datenow - Date.sDate; alert(totaldays); } 回答1: Here's the function I

R Create a time sequence as xts index based on two columns in data.frame

匿名 (未验证) 提交于 2019-12-03 10:24:21
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have a data.frame like below soc_sec group_count total_creds group_start group_end (chr) (int) (dbl) (date) (date) 1 AA2105480 5 14.0 2005-01-09 2005-05-16 2 AA2105480 7 17.0 2004-08-26 2004-12-10 3 AB4378973 1 0.0 2004-01-21 2004-05-07 4 AB4990257 2 1.0 2014-09-01 2014-12-14 5 AB7777777 5 12.0 2004-01-21 2005-03-22 6 AB7777777 6 15.0 2004-08-26 2004-12-10 7 AB7777777 5 15.0 2005-01-09 2005-05-12 8 AC4285291 2 3.0 2014-09-01 2014-12-14 9 AC4285291 1 3.0 2015-01-12 2015-04-15 10 AC6039874 9 17.5 2010-01-06 2010-05-06 11 AC6039874 7 16.0

Show user subscription as cancelled after billing period

匿名 (未验证) 提交于 2019-12-03 10:24:21
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am using Stripe for my subscriptions and I have it set so when a user cancels their subscription (to turn off automatic renewal) it will keep the subscription active until the end of the billing period on Stripe. The action works via Stripe, but how can I setup so that the cancelled column in my database takes the same affect? Currently if the user clicks on the cancel subscription link it will mark their cancelled column to 1 . I would like for it to not mark as cancelled until the end of their billing period so the user can continue have

Oracle (10g) equivalent of DATEADD(weekday, -3, GETDATE())

匿名 (未验证) 提交于 2019-12-03 10:10:24
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm looking for the Oracle (10g) equivalent of: DATEADD(weekday, -3, GETDATE()) from T-SQL (SQL Server) . This subtracts 3 weekdays from the current date. I'm not concerned about holidays or anything like that (and I can truncate the time part off myself). Just excluding weekends is fine. 回答1: It looks like you need to create a UDF. CREATE OR REPLACE FUNCTION business_date (start_date DATE, days2add NUMBER) RETURN DATE IS Counter NATURAL := 0; CurDate DATE := start_date; DayNum POSITIVE; SkipCntr NATURAL := 0; Direction INTEGER := 1; -- days

how to get 30 days from Todays

匿名 (未验证) 提交于 2019-12-03 09:14:57
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Select from x WHERE yid = rid AND (h.test1 <=todaysdate) AND (h.test1>= 30 days from today) How can I write that line 30 days from today in a query? Instead I put a date or a month from todays date. 回答1: In MySQL you can write: SELECT * FROM x WHERE yid=r=d AND h.test1 <= todaysdate AND h.test1 >= ADDDATE(todaysdate, INTERVAL 31 DAY); Are you sure anyway of your request? Don't you want instead (dates before today or after 30 days): SELECT * FROM x WHERE yid=r=d AND (h.test1 <= todaysdate OR h.test1 >= ADDDATE(todaysdate, INTERVAL 31 DAY));

Calculate days since last event, grouped per ID in R

匿名 (未验证) 提交于 2019-12-03 09:13:36
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Have a look at the MWE below: df <- data.frame(date=as.Date(c("06/07/2000","15/09/2000","15/10/2000","03/01/2001","17/03/2001","23/05/2001","26/08/2001"), "%d/%m/%Y"), event=c(0,0,1,0,1,1,0)) id date event 01 2000-07-06 0 01 2000-09-15 0 01 2000-10-15 1 01 2001-01-03 0 02 2001-03-17 1 02 2001-05-23 1 02 2001-08-26 0 02 2001-08-28 0 03 2001-08-29 1 03 2001-09-05 1 03 2001-09-30 0 03 2001-10-12 1 I want, grouped per ID, the number of days since the last event. My question is similar to this one . Only, I want the result grouped per ID: id date

how to get last 14 days of android sms

匿名 (未验证) 提交于 2019-12-03 09:06:55
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am trying to read the last 14 days of android sms messages however it seems to take an eternity to read out all the messages from the Cursor so i limit it to the 1st 100 which dont seem to be in chronological order. Any ideas of an efficient query of th esms data in order to pull the contact and the message only? My code: Uri uriSMSURISent = Uri.parse("content://sms/sent"); // get the sms data for sent Cursor curSent = getContentResolver().query(uriSMSURISent, null, null, null,null); int i=0; while (curSent.moveToNext() && i<100) { String