Questions tagged [datetime]

17199 questions
0

votes
0

answer
27

Views

Plot the difference between two lists of values in matplotlib

I have two datetime based lists. I want to plot the difference between their values. The problem is, the lists are of different lengths / resolutions. For example: list 1 is a list of readings taken every minute throughout the day. list 2 is a list of readings taken randomly throughout the day. I c...
Terence Eden
1

votes
1

answer
57

Views

how to convert string 0000-00-00 in flat file to datetime in database using ssis

i have a .txt file, i using SSIS to import data to database. i has converted string YYYY-MM-DD to datetime using SSIS but string 0000-00-00 is not convert to NULL example if value 2019-02-15 => import data ok, when value 0000-00-00 i want import data to a filed table in database is NULL thanks you!
MuMot
0

votes
0

answer
17

Views

How to fix mysql datetime obj to python datetime

I have a Python script which query a MySQL database. In a part of the code I have to compare if the date for a row is greater than one week for now(). All seems working fine, but for some reason (and only in production) pymysql covert my datetime field from MySQL to a integer (Or at least that's wha...
swperapy
0

votes
0

answer
22

Views

My datetime field in models.py does not work even though it does not raise any exceptions while migrating

In my models.py I have a field created = models.DateField(auto_now_add=True) which does not raise any problems while migrating and such, however when I save a post, it gives me ValueError at /admin/blog/post/ invalid literal for int() with base 10: b'14 21:27:46.098090' I have went through documenti...
Aleksander Jess
1

votes
3

answer
8.4k

Views

Subtract Two DateTime objects - Python [duplicate]

This question already has an answer here: How do I find the time difference between two datetime objects in python? 13 answers I have two date time objects like this a = first date time object b = second date time object And then c = a - b Now I want to compare c and check if the difference was gr...
spenf10
1

votes
2

answer
705

Views

fast way to convert datetime to string

I want to know if there is faster way to convert a datetime to a string besides datestr. datetime is inserted every other lines in my main function (including all of its dependency). I need time at that line of code is executed. I think my only option is to convert datetime to string faster....
Kane
2

votes
0

answer
24

Views

How to get the exact season (autumn, winter, spring and summer) from a datetime vector in R using some built-in package function?

I need to get the exact season (autumn, winter, spring and summer) of my dataset using a "POSIXct" "POSIXt" datetime column. It's important to consider that the seasons depends on equinoxes and solstices on Earth and the exact time it takes places change over years. So it's not as trivial as defin...
guzman
1

votes
2

answer
1.2k

Views

Converting a datetime string (3/24/2017 10:00:00 PM) to (3-24-2017 22:00:00) hive i.e convert from 12 hour to 24 hour format

I have a datetime field in a hive table which is of data type string. It looks as below: datetime 3/24/2017 10:00:00 PM Tried to convert it to the right format desired by hive and also tried removing the AM/PM to a 24 hour format but to no avail. select from_unixtime(unix_timestamp(datetime,'mm-dd-y...
optimus_prime
1

votes
2

answer
1.6k

Views

Converting epoch time to the hour

Given an epoch time: eg (1513213212) I should get 1 since its 1 am right now UTC. How would I go about converting it into the hour of the day? Is it possible to do it just using math (division, mod)?
Fisher Price
0

votes
0

answer
4

Views

Date filter between two dates - Google Data Studio

I'm using Google Data Studio so I can create very easy reports in month by month basis. My main datasource is my MySQL database. So I have a table that has subscriptions details. It has two dates start_date and end_date if the subscription is active the end_date is null. I need to make some calcula...
Fafa0293
1

votes
3

answer
32

Views

Unable to convert index to date format

I have data which is in-64 in the Index with values like "01/11/2018" in the index. It is data that has been imported from a csv. I am unable to convert it to a "01-11-2018" format. How do I do this because I get an error message: 'time data 0 does not match format '%Y' (match)' I got the data from...
AnalysisNerd
1

votes
3

answer
61

Views

Creating Date by iso ''0001-01-01T01:00:00' adding 16 second

new Date("0001-01-01T01:00:00Z") --> Mon Jan 01 0001 02:50:16 GMT+0150 (Moscow Standard Time) Incorrect GMT: my timezone GMT+3000, but date creates GMT+0150
Lina Gurinovich
1

votes
3

answer
62

Views

Formatting UTC timestamp in local timezone

I have a UTC timestamp created with the DateTime class. var time = DateTime.UtcNow; When I format it I get the following result: time.ToString("yyyy-MM-ddTHH:mm:sszzz") > 2019-02-03T10:08:40+00:00 Which is correct but I want it to be formatted in the local timezone like this: 2019-02-03T11:08:40+01:...
LHolleman
1

votes
2

answer
59

Views

Java fastest parser for OffsetDateTime

What is the fastest way to parse date/times into OffsetDateTimes in Java? Is there a library which is faster than the standard library? e.g. OffsetDatetime x = Something.parse("2018-01-02T12:34:56+00:00");
John Smith
1

votes
1

answer
24

Views

Month Range Calculation Doesn't Return Expected Result

If I set the date to following: from datetime import datetime from dateutil import relativedelta class count_month_range: 'Get the month range between 2 specified date based on the timezone' def __init__(self, start_date, end_date, timezone): self.start_date = start_date self.end_date = end_date sel...
FMD
1

votes
2

answer
52

Views

Format Local DateTime with appropriate Local DST-aware Timezone (eg. PST or PDT) depending on time of year

Given a Local DateTime value on a computer configured for PST (which will implicitly change to PDT on March 10th when DST kicks in), how can one obtain a string including the appropriate timezone - eg. PST/PDT, not offset! - in the output? DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss ???") Expected ou...
user2864740
-1

votes
1

answer
40

Views

Order array of string date (“yyyy-MM-dd HH:mm:ss.SSSSSS”) by date

I have an array containing many values And each value contain dateAdd (not nil) I have a func where I'm sorting array like below: func sortByDate(array: [TransactionValues]) -> [TransactionValues] { print(array) let dateFormatter = DateFormatter() dateFormatter.dateFormat = "yyyy-MM-dd HH:mm:ss" let...
Bakhtiyar Ganyev
1

votes
2

answer
6.4k

Views

How to convert iso-8601 timestamp to MySQL DATETIME

I've searched for this conversion and have found the opposite. I'm pulling facebook page feeds using the graph api and the date format it gives is iso-8601. I need to convert that to mysql timestamp to add it to my database. Most search results provide mysql to iso. Can I get a direct conversion o...
Fabian Glace
1

votes
1

answer
31

Views

Search JSON between two dates

I have a JSON object which needs to be searched if I input a angular form with two dates I tried searching using a single date angular form control. template code: Invoice summary Total revenue made by this venue: {{totalRevenue}} Revenue made on {{inputInvoiceDate}} is {{filteredTotalRevenue}...
user464159
0

votes
1

answer
18

Views

How to make endDate's date choose only after startdate's date ASP.NET

I have the current code that make sure the attribute "min" is only today or after. How to make sure that when i choose startDate, I want to make sure enddate is later then the chosen startDate. endDateTb.Attributes["min"] = DateTime.Now.ToString("yyyy-MM-dd"); startDateTb.Attributes["min"] = DateTim...
Jia Hao
0

votes
1

answer
28

Views

datetime combine date & time stamp

Im trying to use this SO post to combine a date and time stamp but not having any luck.. #df= pd.read_csv('C:\\Users\\desktop\\master.csv', index_col='Date', parse_dates=True) df= pd.read_csv('C:\\Users\\desktop\\master.csv') This is where Im stuck, I don't know how to import the package correctly.....
HenryHub
1

votes
3

answer
2k

Views

Plot dates vs values in Python

I have a very standard dataset with 2 columns, 1 for dates and 1 for values. I've put them into two arrays: dates ['1/1/2014', '1/2/2014', '1/3/2014', ...] values [1423, 4321, 1234, ...] How can I create a simple line graph with "values" on the y-axis and "dates" on the x-axis? What I've tried: I ca...
Don P
1

votes
1

answer
19.6k

Views

Validate the date format in vb.net

I have the grid cell value to validate for a correct format as below Date value should be in DD-MON-YYYY format and for this i am using below validation Public Function ValidateDateForError(ByVal checkInputValue As String) As Boolean Dim returnError As Boolean Dim dateVal As DateTime If Date.TryPars...
picnic4u
1

votes
1

answer
1.6k

Views

Dividing a value by number of days in a month in a date field in SQL table

I am working on an SQL query which performs some arithmetic division on the data in a SQL Table based on the value in a date column. To elaborate I have the following SQL table Deals id Date Type Quantity Price 3 2014-11-04 Sweet 2500 23 9 2014-12-04 Sweet 5000 30...
DoIt
1

votes
2

answer
33

Views

How calculate the sum of two DateInterval object

I have two date interval object, is there any default method to add those interval object ? $date1 = date_create("2013-03-15"); $date2 = date_create("2013-12-12"); $diff_1=date_diff($date1,$date2); echo $diff_1->format("%y years").' '.$diff_1->format("%m months"). ' ' . $diff_1->format("%d days");...
Ebin Manuval
14

votes
2

answer
654

Views

What is the origin of the asctime format?

Why was the particular character representation that the asctime function returns, i.e. Www Mmm dd hh:mm:ss yyyy\n, chosen and what is its origin? The ordering of the information seems peculiar to me, especially putting the time information in between the date information. Is this (or was this) a co...
dpprdan
1

votes
4

answer
246

Views

DateTime.ParseExact() confusing

Why I can apply that code to other form .cs string dt = day + "/" + month + "/" + year; DateTime newDate = DateTime.ParseExact(dt, "dd/MM/yyyy", null); It always show error this String was not recognized as a valid DateTime. It have to change like this "dd/MM/yyyy" --> "d/M/yyyy" But in other fo...
0

votes
1

answer
11

Views

pd.datetime not indexing correctly

I have dataset with date of every transaction in restaurant. I tried to set date as index, before converting it with df.to_datetime: df['dateTransaction'] = pd.to_datetime(df['dateTransaction']) df.info() And I really get 'dateTransaction' type as datetime64[ns]. But than I tried to set index with...
Arctic_kh
1

votes
3

answer
1.2k

Views

Converting Time to decimal

All i have to do that just find the overtime of employee. The attendance sheet comes in CSV file and I've already saved the data to a table. The data Field hours is 12:10:00.0000000, and The Working Hour per day is 11:00:00.0000000. I've calculated the difference between these two times using Time...
Saranya Rajendran
5

votes
3

answer
48

Views

Serialize Java8 LocalDateTime to UTC Timestamp using Jackson

I've just converted over many of my Dates to LocalDateTime per the new(ish) java 8 time package. I've enjoyed the switch so far until I started trying to serialize and deserialize. How can I configure Jackson to support them?: LocalDateTime --serialize--> UTC Timestamp --deserialize--> LocalDateTime...
Daniel Patrick
1

votes
0

answer
6

Views

Using a year-field on the x-axis of a lineChart in d3

I am having troubles to implement a data parser using d3. I have a field in my csvdataset that looks like this: .., year, .. .., 1987, .. .., 1988, .. .., 1989, .. .., 1990, .. I would like to use this year dimension on a x-axis of a dc.lineChart. The following is my implementation using crossfilte...
GYBE
1

votes
1

answer
3.5k

Views

Django model DateTimeField set auto_now_add format or modify the serializer

I have this field in my model: createdTime = models.DateTimeField(_('Creation date'), help_text=_('Date of the creation'), auto_now_add=True, blank=True) And it is saved with this format: 2016-05-18T15:37:36.993048Z So I would like to convert it to this format DATE_INPUT_FORMATS = ('%d-%m-%Y %H:%M:S...
lapinkoira
1

votes
2

answer
994

Views

Filter by nullable datetime field using Linq

I'm trying to filter all rows in an SQL table that have a specific date. It works if the column is not nullable, but fails if it is. This works for not nullable datetime fields: ent.MyTable.Where(e => e.MyDate.Day == 12); Obviously this works not for nullable datetime fields. After doing some search...
user1000742
1

votes
1

answer
3.9k

Views

Plotting of pandas DataFrame and xaxis as Timestamp produces empty plot

I have a pandas.DataFrame (df), which consists of some values and a datetime which is a string at first but which I convert to a Timestamp using df['datetime'] = pd.to_datetime(df['Time [dd.mm.yyyy hh:mm:ss.ms]'], format="%d.%m.%Y %H:%M:%S.%f") It seems to work and I can access the new column's ele...
philbox2
1

votes
1

answer
1.7k

Views

Inserting date into SQL server from Java - not formatting properly

I am trying to insert a date into a SQL table in a specific format. I am successfully inserting the date into a column of type datetime, but the formatting is incorrect. I have the following: TimeZone tz = TimeZone.getTimeZone("UTC"); DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");...
mufc
1

votes
3

answer
395

Views

vue2 reactive filter values?

I can't get my computed filter values to update when the vm data updates. In my case, I have some moment datetimes stored on the VM model in UTC. Then I have a filter which displays those times formatted to a timezone using moment. Then I want to have a toggle to switched the timezone if the user wa...
Drew
1

votes
1

answer
3.1k

Views

Converting pandas series timestamp to list of unique dates

I have a column in pandas dataframe in timestamp format and want to extract unique dates (no time) into a list. I tried following ways doesn't really work, 1. dates = datetime.datetime(df['EventTime'].tolist()).date() 2. dates = pd.to_datetime(df['EventTime']).date().tolist() 3. dates = pd.to_da...
PyRaider
1

votes
3

answer
641

Views

PHP intl can convert a Gregorian date to other calendar type

PHP intl can convert a Gregorian date to other calendar type. For example Gregorian to Hijri, 2017/04/11 to 1396/01/22 Or we must use external library to convert dates?
msoa
1

votes
1

answer
1.6k

Views

TypeError: 'datetime.date' object is not iterable while iterating over dict by date

I am trying to iterate over dict, which contains dates as keys: for d, dir in subdirs: print("d=", d, ", dir=", dir) where subdirs is datetime.date(2016, 9, 29): ['tiles/37/U/DB/2016/9/29/0/'],datetime.date(2017, 2, 23): ['tiles/37/U/DB/2017/2/23/0/'], datetime.date(2016, 4, 5): ['tiles/37/U/DB/2016...
Dims
1

votes
1

answer
1.2k

Views

Parsing an ISO8601 date/time in Excel

How to parse ISO 8601 time date format in Excel? I found this example1 but it won't work for me because my format does not have dashes between year-month-day. In other words please help me convert this format 20170427T221520.900Z into UTC date in Excel.
Makaroni

View additional questions