datetime-format

Converting PeriodIndex to DateTimeIndex?

霸气de小男生 提交于 2019-11-30 21:35:20
I have a question regarding converting a tseries.period.PeriodIndex into a datetime. I have a DataFrame which looks like this: colors country time_month 2010-09 xxx xxx 2010-10 xxx xxx 2010-11 xxx xxx ... time_month is the index. type(df.index) returns class 'pandas.tseries.period.PeriodIndex' When I try to use the df for a VAR analysis ( http://statsmodels.sourceforge.net/devel/vector_ar.html#vector-autoregressions-tsa-vector-ar ), VAR(mdata) returns: Given a pandas object and the index does not contain dates So apparently, Period is not recognized as a datetime. Now, my question is how to

How to parse datetime with optional sections?

◇◆丶佛笑我妖孽 提交于 2019-11-30 21:15:22
问题 I've datetime that may be one of the following formats: MM/dd/yy M/dd/yy MM/d/yy M/d/yy Any of the above with HH:mm Any of the above with 4-digit year The DateTimeFormatter I built is as follows: new DateTimeFormatterBuilder() .appendValue(ChronoField.MONTH_OF_YEAR, 1, 2, SignStyle.NEVER) .appendLiteral('/') .appendValue(ChronoField.DAY_OF_MONTH, 1, 2, SignStyle.NEVER) .appendLiteral('/') .appendValue(ChronoField.YEAR_OF_ERA, 2, 4, SignStyle.NEVER) .optionalStart() .appendLiteral(' ')

Why doesn't DateTime.ParseExact parse UTC format with the trailing Z?

眉间皱痕 提交于 2019-11-30 14:03:14
问题 Another ParseExact problem. I'm trying to parse a UTC formatted string to a datetime with the format of: "YYYY-MM-DDThh:mm:ss.ssZ" which is in UTC format, with the trailing Z. I can't parse exact it for some reason. I have tried the "u", "s", "o" custom format strings, as well as as several DateTimeStyles and well as handwritten. The culture is invariant. For some reason it doesn't like the Z, which indicates it's a UTC string. When I remove it, parses. I would happily, with some satisfaction

.NET Date to string gives invalid strings in Vista Pseudo-cultures

扶醉桌前 提交于 2019-11-30 10:59:21
My computer is configured with a culture that is not en-US . When using the native Win32 GetDateFormat function, i get correctly formatted dates: 22//11//2011 4::42::53 P̰̃M] This is correct; and is also how Windows renders it: the taskbar Region and Language settings Windows Explorer Outlook When i try to convert a date to a string in .NET using my current locale, e.g.: DateTime.Now.ToString(); DateTime.Now.ToString(CultureInfo.CurrentCulture); i get an incorrect date: 22////11////2011 4::::42::::53 P̰̃M] This bug in .NET is evident anyplace in Windows that uses the buggy .NET code: Windows

Convert a string with 'YYYYMMDDHHMMSS' format to datetime

不打扰是莪最后的温柔 提交于 2019-11-30 08:52:23
I recognize there has been many questions posted about converting strings to datetime already but I haven't found anything for converting a string like 20120225143620 which includes seconds. I was trying to perform a clean conversion without substring-ing each segment out and concatenating with / and : . Does anyone have any suggestions? You can use the STUFF() method to insert characters into your string to format it in to a value SQL Server will be able to understand: DECLARE @datestring NVARCHAR(20) = '20120225143620' -- desired format: '20120225 14:36:20' SET @datestring = STUFF(STUFF

Filter by datetime MYSQL formatting

心已入冬 提交于 2019-11-30 08:46:05
I have a Mysql Table that is used for a log file on the that table there is a field called 'log_date' And it stores the date in the following format( %Y-%m-%d %H:%i.%s ).On the DB the dates look like something this 2013-20-05 00:00.00. Lets say today's date is 2013-20-05 And I have log files from 2013-01-01 to present day. If I run a query like this: SELECT * FROM log_table WHERE STR_TO_DATE(log_date, '%Y-%m-%d %H:%i.%s') < '2013-05-05 00:00.00' This is returning every row in the DB including rows that are greater than 2013-05-05 00:00.00 And if I reverse the < (less then) to a > (greater then

Why does DisplayFormat with DataFormatString changes “/” (slash) to “-” (dash)?

ε祈祈猫儿з 提交于 2019-11-30 08:34:45
I'm using the following code // Model [DisplayFormat( ApplyFormatInEditMode = true, DataFormatString = "{0:dd/MM/yyyy}")] public DateTime StartDate { get; set; } // View @Html.EditorFor(model => model.StartDate) to format the StartDate but the result is xx-xx-xxxx instead of xx/xx/xxxx . How can I solve this and always use the xx/xx/xxxx format? UPDATE: Changing the culture to en-US seems to work: var culture = new CultureInfo(userCulture); System.Threading.Thread.CurrentThread.CurrentCulture = "en-US"; System.Threading.Thread.CurrentThread.CurrentUICulture = "en-US"; but this is not a

Datetime format issue in IIS 7 server

冷暖自知 提交于 2019-11-30 07:55:40
I have hosted one of my site on IIS 7, WS2008. Later i have realize there is some datetime format issue, like me expecting things in dd/MM/yyyy format but it was in MM/dd/yyyy format and because of this it used to give me datetime conversion error. So i have changed the datetime format by following step: Control Panel -> Regional and Language Options -> Advanced and changed registry entry regedit >> HKEY_USERS>>DEFAULT>>Control Panel>>International and here we have changed "sLongDate" and "sShortDate" key in dd MM yyyy format and restarted the server. Now, the issue is if i create new website

Convert Date time to specific format in C#

别等时光非礼了梦想. 提交于 2019-11-30 07:41:42
I want to convert date time to specify format that is Wed Aug 01 2012 14:37:50 GMT+0530 (India Standard Time) Actually i want to display the Timer using Jquery on web page. So i have tried some format i knew. And found some from http://www.dotnetperls.com/datetime-format But none of them return the result what i require. Actually i have to pass the time from server So i have tried the following code. Code Behind protected void Button3_Click(object sender, EventArgs e) { //string hello = DateTime.UtcNow.ToString(); string hello = String.Format("{0:F}", DateTime.UtcNow); DateTime.UtcNow.ToString

In an ISO 8601 date, is the T character mandatory?

拜拜、爱过 提交于 2019-11-30 05:40:32
I'm wondering if the following date is ISO8601 compliant : 2012-03-02 14:57:05.456+0500 (for sure, 2012-03-02T14:57:05.456+0500 is compliant, but not that much human readable !) IOW, is the T between date and time mandatory ? It's required unless the "partners in information interchange" agree to omit it. Quoting the ISO 8601 standard , section 4.3.2: The character [T] shall be used as time designator to indicate the start of the representation of the time of day component in these expressions. [...] NOTE By mutual agreement of the partners in information interchange, the character [T] may be