Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- "2016-05-12T23:59:11+00:00"
- "2016-05-13T11:00:11+00:00"
- "2016-05-13T23:59:11+00:00"
- "2016-05-15T10:10:11+00:00"
- "2016-05-16T10:10:11+00:00"
- "2016-05-17T10:10:11+00:00"
- def fn(dateTime):
- df1=pd.DataFrame()
- query = """ SELECT "recordId" from "Table" where "dateTime" BETWEEN %s AND %s """ %(dStart,dEnd)
- df1=pd.read_sql_query(query1,con=engine)
- return df1
- fn('2016-05-12','2016-05-15')
- def fn(dStart, dEnd):
- query = """
- SELECT "recordId"
- FROM "Table"
- WHERE "dateTime" >= %(start)s AND "dateTime" < %(end)s + interval '1 day'
- """
- query_params = {'start': dStart, 'end': dEnd}
- df1 = pd.read_sql_query(query1, con=engine, params=query_params)
- return df1
- import time
- time_data = ["2016-05-12T23:59:11+00:00",
- "2016-05-13T11:00:11+00:00",
- "2016-05-13T23:59:11+00:00",
- "2016-05-15T10:10:11+00:00",
- "2016-05-16T10:10:11+00:00",
- "2016-05-17T10:10:11+00:00"]
- def fn(t_init, t_fin, t_all):
- # Convert string inputs to struct_time using time.strptime()
- t_init, t_fin = [time.strptime(x, '%Y-%m-%d') for x in [t_init, t_fin]]
- t_all = [time.strptime(x, '%Y-%m-%dT%H:%M:%S+00:00') for x in time_all]
- out = []
- for jj in range(len(t_all)):
- if t_init < t_all[jj] < t_fin:
- out.append(jj)
- return out
- out = fn('2016-05-12','2016-05-15', time_data)
- print(out)
- # [0, 1, 2]
- %Y Year with century as a decimal number.
- %m Month as a decimal number [01,12].
- %d Day of the month as a decimal number [01,31].
- %H Hour (24-hour clock) as a decimal number [00,23].
- %M Minute as a decimal number [00,59].
- %S Second as a decimal number [00,61].
- %z Time zone offset from UTC.
- %a Locale's abbreviated weekday name.
- %A Locale's full weekday name.
- %b Locale's abbreviated month name.
- %B Locale's full month name.
- %c Locale's appropriate date and time representation.
- %I Hour (12-hour clock) as a decimal number [01,12].
- %p Locale's equivalent of either AM or PM.
Add Comment
Please, Sign In to add comment