Questions tagged [datetime]

22562 questions
1

votes
1

answer
50

Views

how to convert pandas time data into the format that can be processed by matplotlib

in the 3 section of lecture, i encounrtered a problem that I could not upload any finance data from yahoo, so I use pandas datareader to uploaded a stock info for microsoft here is that code: MS= data.DataReader(name = 'MSFT', data_source = 'yahoo', start = '2007-07- 10', end = '2008-12-10') MS.head...
Xiaoyang Wu
1

votes
3

answer
36

Views

SQL - Get Records within Date Range using 2 tables (Date Range/Hours given)

I have 2 tables: Table 1: Name, StartDate, EndDate Ex: Timmy, 9/12/17 08:00:00, 9/13/17 00:00:00 Timmy, 9/13/17 05:00:00, 9/13/17 07:00:00 Table 2: Name, StartHour, Data... Ex: Timmy, 9/13/17 06:00:00, Data1... Timmy, 9/13/17 04:00:00, Data2... Timmy, 9/13/17 07:00:00, Data3.....
Future44
1

votes
0

answer
714

Views

Call to a member function getTimestamp() on boolean

I got this error whatever format i changed, i have no idea what else causes of this. Can someone help me on this? My csv excel dateTime format is yyyy/mm/dd H:mm $i = 0; $len = count($map_column); $insData = array(); foreach ($map_column as $key => $value) { $i++; if ($key == 'dateTime') { $da...
Sara
1

votes
1

answer
242

Views

Custom PeriodIndex (Python / Pandas equivalent to SAS INTNX)

I have a SAS background and I am new to Python. I would like to how to use PeriodIndex in a similar way that we use SAS intervals. This is my problem: We have an official interest rate that is published more or less monthly. This interest rate is valid until the next one is published. My objective i...
Bruno
1

votes
0

answer
46

Views

Maintain timezone awareness with date and time arithmetic

According to Django : RunTimeWarning : DateTimeField received a naive datetime while time zone support is active, get today's date with timezone information with from django.utils import timezone today = timezone.now() When I do: from datetime import timedelta yesterday = today - timedelta(days=1) B...
Code-Apprentice
1

votes
1

answer
224

Views

Calculate performance vs LY with shifting month dates

I've tried so many times to solve this, but failed. Question: I help on a solution on how to calculate Current Year divided by last year in our Fiscal Year, month by month, where last years date differs from this years date Scenario I want to see how we performed on revenue January 2017 vs. Januar...
Dendera
1

votes
1

answer
370

Views

Pandas: Convert Month Name to Int + Concat to Column and Convert to Date time

Convert Month Name (ex.October) to int value. Append this column 'Month' to the beginning of another column 'FY' Convert new column 'Month FY' to date I've tried to used pandas, calendar, datetime, but have been unsuccessful. I would like to accomplish this without having to create a dict. End Goal...
G.G.
1

votes
1

answer
57

Views

Filtering by datetime confusion

I have a datetime object that is not the index and when I filter it by: df=df[(df['local_time']>=datetime.date(2015,2,18))] df=df.sort_values('local_time',ascending=[True]) why does df.head(1) show 2-17-2015 as the first date when im using: >=datetime.date(2015,2,18)
Danny W
1

votes
0

answer
59

Views

Timestamp in log changed cultureformat from 24h to 12h during runtime

I'm writing this question in the hope that you could lead me in the right direction regarding our current logging timestamp (on some servers). During a deployment session we noticed that the timestamp format changed from 24h to a 12h am/pm format. This change was not intervened by the deployment tho...
Rane Balslev
1

votes
2

answer
176

Views

INSERT TIMESTAMP or DATETIME fails when month, day, hour or min is 8 or 9

I'm having a strange problem while dealing with inserting datetime values. it happens while inserting DATETIME or TIMESTAMP type columns, as well as when using STR_TO_DATE function. it seems that the database cannot parse correctly when the month, the day, the hour or the minute are number 8 or 9. S...
agregorio
1

votes
0

answer
82

Views

Pandas Erratic Sorting by DateTime column

I have a pandas dataframe, and after reading some comments (thank you) would like to clarify. I have defined my BeginDate column as data['BeginDate'] = pd.to_datetime(data.BeginDate) data = data.sort_values(['BeginDate'], ascending = [False]) by printing type(data['BeginDate']) it returns BeginD...
Frank Drin
1

votes
2

answer
915

Views

Powershell convert string to date

I am putting together some custom monitoring solutions and the logs include different date/time entries. Trying to parse the date/time (text value) from the log and convert into a date value so that I can compare with others or with system date. I have used the following in the past, but am having t...
Allin Brown
1

votes
1

answer
204

Views

Parsing SAS datetime to pandas dataframe

I'm loading a CSV that was produced with SAS into a pandas DataFrame. In order to parse the SAS times I created a parser function like this: def parse_date(d): try: date = dt.timedelta(seconds=int(d)) + dt.datetime(1960, 1, 1) return date except ValueError: print('There was a problem parsing.') Now,...
CrunchyCruncha
1

votes
2

answer
44

Views

Converting Text to Date Time

I want to convert the below column to DateTime, I tried using as.Date, anytime but I get wrong answer. Please see below: time_stamp 20171001010114 20171001015436 20171001092516 20171001093101 20171001093739 20171001095059 20171001100741
Mirza Hashim
1

votes
1

answer
811

Views

How to add Date Header to an WebRequest

I am trying to add a 'Date' to an WebRequest Header.But it returns an error as 'The 'Date' header must be modified using the appropriate property or method. Parameter name: name'.I need to pass an Date header to an request. So I tried using HttpWebRequest,It has Date property. But what is my problem...
Girija
1

votes
1

answer
37

Views

Check if “now()” and timestamp from a db aren't different than 3 days

I'm using Phoenix and Ecto. I need to check if a difference between 'now()' and a certain date less than 3 days. Exactly I'm trying this: {diff_days, {_, _, _}} = Ecto.DateTime.to_erl(my_user.signed_up_at) |> :calendar.time_difference(:calendar.universal_time) if diff_days
1

votes
1

answer
31

Views

Issue with Powershell Excel attempting to cast .csv Values

At this point, I believe it may be a file I/O issue. While utilizing a Powershell script invoking Excel methods to go through a .csv file from a website, powershell is attempting to cast placeholders for data that is too long for a cell '#######' instead of the date and time contained within the '...
LifeOfThePotty
1

votes
1

answer
85

Views

EVReflection.setDateFormatter() supporting multiple formats

I have encountered a problem with deserialization of my DateTime strings from JSON in swift. I have entity containing multiple NSDate values (which are received from .NET WebAPI server). My problem is that some of JSON properties contain date strings formatted like this: 'yyyy-MM-ddTHH:mm:ss' and so...
TipsyFingers
1

votes
1

answer
279

Views

How to configure web api's json serializer to convert date time into ISO 8601 format?

I am working on web api project and inside my WebApiConfig class I have added this configuration to convert datetime parameters into ISO 8601 format: IsoDateTimeConverter converter = new IsoDateTimeConverter { //DateTimeStyles = DateTimeStyles.AdjustToUniversal, DateTimeFormat = 'yyyy'-'MM'-'dd'T'HH...
Simple Code
1

votes
0

answer
223

Views

Set default “to date” in ng2 datetime “from to datepicker”

Update: If I remove giving datepicker options from html, it works but I want to set default options like autoclose and all. I am using https://nkalinov.github.io/ng2-datetime/ for a 'from to' datepicker. I am able to set default date for the from datepicker whereas the to datepicker shows choose dat...
RemyaJ
1

votes
1

answer
21

Views

Python: Adding Input To A Time Elapsed Calculator

I wrote a program that calculates the number of days between two dates. I'm having trouble writing the program so that it asks for user input. How can I do this without raising any errors? import datetime class User: def __init__(self, date_one, date_two): self.date_one = date_one self.date_...
Aiden Kolodziej
1

votes
0

answer
30

Views

How to query compare between rows in collection ElasticSearch

I have data in Elasaticsearch like this: {'number1':1 ,'result':0 , 'date':'2018-01-17T01:00:57Z'} {'number1':5 ,'result':0 , 'date':'2018-01-17T02:00:57Z'} {'number1':6 ,'result':0 , 'date':'2018-01-17T03:00:57Z'} {'number1':4 ,'result':0 , 'date':'2018-01-17T04:00:57Z'} I want to query result: {'n...
1

votes
0

answer
34

Views

Datetime column in dataframe is preventing me from writing to excel

I have a dataframe containing data in five columns. A sample of the dataframe is at the bottom of my post. The first column is all date times (first row is 2017-05-26 19:00:00 for formatting example). I have the below code for writing to excel, which works when I exclude the datetime column. dat =...
Callum Wayman
1

votes
1

answer
40

Views

Turn abbreviated months in 4 different languages into corresponding month number

I have English, German, French and Spanish abbreviations of months and I must return it as a number so 'dic' would be 12 //es or 'avr' would be 4 //fr I also have the locale that would be used This is what the inputs looks like
Jeremy
1

votes
1

answer
511

Views

Converting from UNIX Timestamp to datetime results in OSError: [Errno 22] Invalid argument

I'm retreiving an endpoint from an API that comes back as: Date(1516367982230) I named this SentDate in my script. The number between the brackets is a UNIX time stamp. I want to convert this to a normal date and time so I used a function I found on stackoverflow: SentDate = dt.datetime.fromtimestam...
Henk de Vries
1

votes
0

answer
592

Views

How to set system datetime in UTC

So i need to script setting the system datetime from commandline (CMD.exe, BATCH possible) but im facing difficulties with time zones vs UTC and such. My datetime source is UTC, which is the most portable and therefor makes sense. Originally this code was implemented using (and equivalent for date p...
BNT
1

votes
1

answer
67

Views

Setting Date with year, month, day, hour, minute, seconds, and UTC offset values

If I had the following values: const year = 1890 const month = 6 const day = 1 const hour = 5 const minute = 50 const second = 0 const utcOffset = -10 How do I set either a Javascript date or a momentJS date for June 1 1890 5:50 (in the morning) with UTC Offset of -10 ? All I can see in the internet...
preston
1

votes
0

answer
80

Views

.net datareader changing a date within string/varchar returned from SQL Server

Problem In trying to get the week end date, the VB.NET DbDataReader seems to be changing the date within a string that is returned back from the database. Using 18-jan-2018 and 1-mar-2018 as the start and end dates respectively, I expect to get back the following strings from the database. Week Endi...
kolin
1

votes
2

answer
1.2k

Views

Query to convert UTC to CST

I'm using SQL Server to count rows in a 24 hour period. I've accomplished that, however I can't figure out how to convert the UTC time to CST that the database stores. Then... How to breakdown the 24 hours into 24 x 1 hour blocks with a SUM or Count of each hours rows? Convert UTC TIME to CST? Que...
PJ Ehsani
1

votes
3

answer
215

Views

Date Format with Locale

I want to display date according to each country's date format. I have tried many ways finally I found this example http://www.java2s.com/Code/Java/Data-Type/DateFormatwithLocale.htm Which gives the perfect output of what I meant. Some countries like Germany won't use 12hr formats instead they uses...
Adhithya G Nair
1

votes
2

answer
30

Views

matlab table timestep calculation

Is there a way to access the column data without having to type table_name.VariableName (:,:)? I need to find the delta time from the time stamp of the data. This is what I have done so far: [u,v]=size(a); b=cell2table(cell(u,1)); for i=1:u if i==1 b(i,1)={'0'}; else b(i,1)=(datenum(a.PCTimestamp_No...
user3748556
1

votes
0

answer
72

Views

.NET does not deserialize correctly DateTime values in DataSet serialized to XML

I am writing a program that serializes a DataSet into a XML file, then the same program deserializes it in another computer to save it into a database. For serialization/deserialization I use the DataSet ReadXml/WriteXml methods. The problem is that .NET isn´t deserializing DateTime values correctl...
Alejandro
1

votes
1

answer
141

Views

DateTime::diff unexpected results

I have the following calculation, which I expect to return 0. However it returns 1 on many systems I have access to: Ubuntu 16.04 server (wrong) php -v PHP 7.0.22-0ubuntu0.16.04.1 (cli) ( NTS ) Copyright (c) 1997-2017 The PHP Group Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies with Z...
jdog
1

votes
2

answer
34

Views

How to reduce POSIXct time to previous 15-second interval for multiple time stamps in R

I have a bunch of time stamps ( that are in a POSIXct format. The following are some examples of the timestamps I have: 2017-01-20 16:44:02 2017-01-20 17:14:59 2017-01-20 17:17:21 I am trying to get the timestamp reduced to the previous 15-second interval (00:00, 00:15, 00:30, 00:45) so the followi...
Andy
1

votes
3

answer
1.2k

Views

Changing DateTime format in lambda Expression

I have a DTO field in DateTime format public DateTime date_joined { get; set; } I use this to turn the data into a Json public JsonResult Customer(int? id) { var user = User.Identity.Name; if (!AccountController.IsInRole(user, 'admin')) { return null; } id = id == null ? 0 : id; var customer = db.Pr...
Ege Bayrak
1

votes
1

answer
319

Views

Pandas datetime format to prevent NaT

I am reading in an excel file into python with pandas. xls = pd.ExcelFile('filename.xlsx') df = xls.parse('Sheet1') I have a column in my dataframe (time_since_illness_onset) with datetime objects of the form: 1900-01-03 00:00:00 1900-01-04 04:30:00 I would like to parse these so that I have a col...
user42527
1

votes
0

answer
72

Views

DateTimeOffset is parsed incorrectly in WebAPI

I have the problem that when I send my json-object to my API, the DateTime is reset by one hour. I already read that I should use DateTimeOffset. I did that too, but I get the same result. An example of what my object looks like: { 'Person': { 'Birthday': '2000-01-26T00:00:00+01:00' } } So everythin...
Hadda
1

votes
1

answer
72

Views

datetime.datetime(2017, 4, 6, 1, 44, 44, tzinfo=<UTC>) django

When i create my Model serializer with django-rest-framework and try to get from URL i got the next error 'unicode' object has no attribute 'tzinfo' But when i execute the shell of django a = Model.objects.all()[0:1] a[0].upload_date This is printed in shell datetime.datetime(2017, 4, 6, 1, 44, 44...
Julianjp
1

votes
0

answer
27

Views

Mysql, organizing dates of the tasks based on priority and number of working hours every day

I want to build a small app for myself to organize my tasks. I created a task table as follows: CREATE TABLE TASK( TASK_ID INT NOT NULL AUTO_INCREMENT, TASK_NAME VARCHAR(100), TASK_DESCRIPTION VARCHAR(300), TASK_ASSIGNEE_ID_PRIMARY VARCHAR(32), PERCENTAGE_COMPLETED INT3, PLANNED_DATE_START DATE, PL...
Wojciech Orzechowski
1

votes
0

answer
35

Views

How to add dates to remote sensing data?

I am working with remote sensing data to create time series of NDVI and Cloud cover. The data consists of 30 rows (latitude) and 40 columns (Longitude) and 212 matrix slices which are the months from 2000-03 until 2017-10. How ever R sees the data as an array and there is no date visible in the data...
Francis Criens

View additional questions