FAQ Database Discussion Community


Regex - the difference in \\n and \n

php,regex,datetime,syntax,sscanf
Sorry to add another "Regex explanation" question to the internet but I must know the reason for this. I have ran this regex through RegexBuddy and Regex101.com with no help. I came across the following regex ("%4d%[^\\n]") while debugging a time parsing function. Every now and then I would receive...

Don't understand tm_struct (C++) calculations - is there an offset of some kind? [closed]

c++,date,datetime
I can't understand why the tm struct in C++ behaves this way. Let me be more specific - if I were to get the current time, I'd probably do something like this time_t now = time(0); tm *nowTm = gmtime(&now); And upon printing out the date, I expect something like...

Converting DateTime throws SqlDateTime overflow

c#,datetime
Currently I've a string with a date and time. When I show the string it looks like: 2015-06-16 09:17:28 PM But when I try to put it into the database it's telling me: Additional information: SqlDateTime overflow. Must be between 1/1/1753 12:00:00 AM and 12/31/9999 11:59:59 PM. I've to convert...

Converting string to datetime in mapping to viewmodel

c#,asp.net-mvc,datetime,entity-framework-6
I have an MVC app where I collect DateTime fields (MM/dd/yyyy) as strings to avoid Chrome overriding the datepicker in bootstrap and to avoid mapping in sqlbulk upload of Excel. I now need to map this string field back to datetime and am struggling with this greatly. Here's my Model:...

Is there a single DateTime Picker component for gwt?

java,date,datetime,gwt
I need to use a single date time picker component. Currently, I am using DateBox but I need to pick hours also. As far as I can see, with DateBox I can specify Input Date Format like "MM/dd/yyyy/hh/mm" and I can edit the hours and the minutes with the keyboard....

How to change date-time format?

sql-server,date,datetime,sql-server-2014
I have a RegDate column of nvarchar(max) type in my table in which dates are stored in mm/dd/yyyy (5/22/2015 11:09:39 PM) and dd-mm-yyyy (19-05-2015 22:55:05) format. I want to get all these entries in one format i.e. dd/mm/yyyy. I tried to convert it by using Convert(varchar(10),cast(vr.RegDate as DATETIME),105) as RegistrationDate...

Convert a specific format dateTime string to DateTime in C#

c#,asp.net,datetime
I have a formatted datetime string and I want to convert it back to DateTime but when I parse or convert that string to DateTime it throws exceptio that string is not a valid dateTime. Here is how DateTime string is created string temp = dt.Year.ToString("D4") + dt.Month.ToString("D2") + dt.Day.ToString("D2")...

Paypal IPN return datetime formatting

php,datetime,paypal,paypal-ipn
Palpal sandbox IPN returning datetime as Mon Jun 15 2015 12:04:00 GMT+0600 (Azores Standard Time). How to format this in PHP? Please look at my date format. This is not duplicate.

Choose results by date filter PHP and MySQL

php,mysql,datetime,phpmyadmin
I have one page (members.php) that post date to another page (results.php). Using the below code, i can successfully get the "to" and "from" variables from the members page. <?php echo $_POST["to"]; ?> <?php echo $_POST["from"]; ?> My problem now is, how can i create a query (in results.php) in...

Given an array/object of datetimes, how can I return an array/object of the times sorted by hour and times sorted by days of the week

php,arrays,sorting,datetime,laravel
PHP/Laravel, I'm getting an array of objects that includes date times for each record. I need to generate analytics on objects on an hourly basis of a day and daily basis of a week. So for example: For a date range of 1/1/2015 - 1/10/2015 I return 100 records all...

convert time to to 12 hour by manipulate string

javascript,jquery,datetime,time
"2015-06-23 14:00:00" I tried to format above date time into 12 hour base but stuck in somewhere. function formatDate(raw_date){ var right = raw_date.substring(10, 0); var hours = ((right[0].substring(2,0) + 11) % 12 + 1); var min = raw_date.substring(14,16); var suffix = right[1] >= 12 ? "PM":"AM"; right[1] = ((right[1] +...

Python Datetime into MySQL

python,mysql,csv,datetime
I'm parsing several years worth of daily solar generation CSV files that look like this (with YY-MM-DD.CSV filename format) sep=; Version CSV|Tool SunnyBeam11|Linebreaks CR/LF|Delimiter semicolon|Decimalpoint point|Precision 3|Language en-UK|TZO=0|DST|11/03/2012 ;SN: xyz ;SB blah ;xyz Time;Power HH:mm;kW 00:10;0.000 00:20;0.000 00:30;0.000 00:40;0.000 00:50;0.000 01:00;0.000 01:10;0.000 01:20;0.000 01:30;0.000 01:40;0.000 01:50;0.000 02:00;0.000 02:10;0.000 02:20;0.000 02:30;0.000...

SQL Server Job history 2008 R2

sql-server,sql-server-2008,datetime
I have many jobs scheduled in SQL Server R2. And each job may contain several Steps under it. I want the lastrundate, lastrunstatus, lastrunduration, lastrunmessage, nextrundate FOR EACH AND EVERY STEP under EACH JOB. I have this query with me which works fine. The only issue is, it is not...

DateTime.Parse ignoring my IFormatProvider?

c#,.net,parsing,datetime
It looks to me like .NET is ignoring the TwoDigitYearMax property of the CultureInfo (IFormatProvider) I pass for parsing? Specifically, I cannot explain why the last line of this says 1930, and not 2030. Can anyone reproduce or explain it? Windows 7, .NET 4.0, en-US system settings. using System; using...

getting datetime from current timestamp default

php,mysql,datetime
When users first create their accounts it by default puts the current timestamp in the "date" field which is a timestamp type. It won't allow me to make the default value the current datetime if the field type is "datetime". I can only do that with "timestamp". But now I'm...

Android/Joda time - Convert dateTime to my local DateTime

android,datetime,timezone,jodatime
I am trying to convert server date string to my local/device set local time but without success. I am using Joda time library. What i am trying to do: private static String FORMAT_DATE_SERVER = "YYYY-MM-dd'T'HH:mm:ssZ"; public static DateTime parseServerDateToLocal(String raw_date) { DateTime result = DateTime.parse(raw_date, DateTimeFormat.forPattern(FORMAT_DATE_SERVER)).withZone(DateTimeZone.getDefault()); return result; } Still...

PostgreSQL - aggregating data by date from datetime field

postgresql,datetime
I have data over time for particular users and timestamp of the form 2013-11-23 16:00:00-05 - there's by minute by minute date for each user and corresponding usage value. So the table has values: user_ID, localminute, usage. I am trying to aggregate usage at a day wise level, what i...

converting “1984-03-25 02:00:00” to POSIX gives NA

r,datetime,posix,na
While converting a vector of date-time to POSIXlt, just one particular time "25-Mar-1984-02:00" "is converted to POSIXlt but returns NA! So, this row was getting omitted in my analysis/plots. is.na(as.POSIXlt("25-Mar-1984-02:00",format = "%d-%b-%Y-%H:%M")) is.na(as.POSIXlt("25-Mar-1984-03:00",format = "%d-%b-%Y-%H:%M")) is.na(as.POSIXlt("25-Mar-1984-01:00",format = "%d-%b-%Y-%H:%M")) is.na(as.POSIXlt("24-Mar-1984-02:00",format = "%d-%b-%Y-%H:%M")) is.na(as.POSIXlt("26-Mar-1984-02:00",format = "%d-%b-%Y-%H:%M")) returns TRUE, FALSE, FALSE,...

Python timedate match

python,regex,sqlite,datetime
I have a function that I call which generates a timestamp on a event that comes through a For loop. Function, and RAW timestamp def atimer (): timenow = time.time() return(timenow) print timenow 1434615010.27858 The timestamp looks like this "1434615010.27858", which is nice and small for database use in sqlite3....

Issue on converting time from local to UTC at DST end date while using TimeZoneInfo.ConvertTimeToUtc(DateTime, TimeZoneInfo) method

c#,.net,datetime,timezone
I have an application that converts local time to UTC and stores it in the database. I encountered this problem while I was testing the conversion during a particular date - 1st November, 2015(the date on which the Daylight savings time ends(the clock goes back to 1.00AM on reaching 2.00AM))....

Format DateTime.ParseInfo

c#,datetime,kendo-grid
Good morning, I have problem with format of datetime which comes in format "Mon Jun 15 2015 00:00:00 GMT+0200 (Central Europe Daylight Time)". var value = "Mon Jun 15 2015 00:00:00 GMT+0200 (Central Europe Daylight Time)"; DateTime.Parse(value) throws CastException. I have also tried use ParseExact method which is more powerfull...

The specified value does not conform to the required format yyyy-MM-dd

jquery,asp.net-mvc,google-chrome,datetime,data-annotations
I have a .Net MVC 5 application that is using Data Annotations, Entity-Framework Jquery 2.1.3 and Jquery UI 1.11.4. When I render an edit form with an input of type date using the UK format "dd/MM/YYYY"; the following error message appears when using Google Chrome: The specified value '10/10/2001' does...

Getting time difference in python 2.7

python,datetime
I am importing some data from a REST API into a list. One of the columns contains just date/time information. Column A format/example : 2015-06-11 07:59:10.000 GMT I need to be able to check the time difference between two rows , i tried using datetime.strptime(variable_name, "%Y-%m-%d %H:%M:%S") however i got...

SQL Invalid ALTER TABLE option

sql,oracle,datetime,add,alter-table
With the following SQL statement: ALTER TABLE USERS ADD LAST_LOGIN DATETIME() I am receiving the error below: Error report - SQL Error: ORA-01735: invalid ALTER TABLE option 01735. 00000 - "invalid ALTER TABLE option" *Cause: *Action: I cannot for the life of me understand why SQLDeveloper does not like the...

I need to dynamically set the date in a where statement to only pull results from a table to occur in County's fiscal year

sql,sql-server-2008,date,datetime,visual-studio-2008
Here is my current code: SELECT nature, inci_id, calltime, agency, gp FROM inmain AS inmain WHERE (calltime >= CONVERT(DATETIME, '2013-07-01 00:00:00', 102)) AND (calltime <= CONVERT(DATETIME, '2014-06-30 23:59:59', 102)) ORDER BY nature, calltime I need this to pull data at the end of every fiscal year without going in and...

How to format the given time string and convert to date/time object

java,date,datetime,datetime-format
I am getting the time object in the form of a string from a rest service . I need to extract the time and then do some time operation.The given time string is "2015-06-16T14:58:48Z". I tried the below code , to convert the string to the time , however ,...

Date not binding with model for specific culture

jquery,asp.net-mvc,datetime,momentjs,globalization
I am trying to bind date in a model for two cultures (en-US and fr-FR) when the culture is selected en-US. User selects the Item language for creating an entry. For example : Add news in en-US | add news in fr-FR Model: [Column(TypeName = "datetime2")] public DateTime CreatedOn {...

Translation of interval

postgresql,datetime,translation,intervals,postgresql-8.4
There is maybe a way to translate automatically interval as it's shown by postgresql (e.g. "1330 days 10:54:54.266684") to other languages? For instance using locales, or other settings or I have to use replace, e.g. regexp_replace((now()-t.another_date)::text, 'day','dzień')?

DateTime.ParseExact doesn't work as i expect

c#,datetime
I'm trying to parse a DateTime (in C#) from en-US to de-DE or just in a different Format. The input DateTime is 06/17/2015 09:22:30 AM. What i've tried: DateTime date = DateTime.ParseExact(dateString, "d.MM.yyyy HH:mm:ss", new CultureInfo("de-DE")); or DateTime date = DateTime.ParseExact(dateString, "d.MM.yyyy HH:mm:ss", CultureInfo.InvariantCulture); in both versions i have the...

Converting PST time to Local device time in android

android,datetime,timezone
I am trying to convert PST time to Device local time using below function. It works fine but in London timezone its not working properly. If its 04:58 AM PST then it should show 12:58 PM as per London timezone but its showing 12:58 AM. Am i doing anything wrong...

Parsing string into DateTime [duplicate]

c#,datetime
This question already has an answer here: Parse string to DateTime in C# 5 answers I have a string and I have to convert it into DateTime type. '11 Jun 2015 (12:10)' I have to parse it into DateTime. I have used DateTime.Parse("MyDateString") but it is throwing an exception....

Latest two datetime in SQL Server

sql,sql-server,datetime
I have following table CREATE TABLE [dbo].[events] ( [event_id] [nvarchar](50) NULL, [event_timestamp] [datetime] NULL, [reading] [int] NULL ) ON [PRIMARY] with the following data and resutls Table: events event_id event_timestamp Reading --------------------------------- 1200 14-Jun-15 1500 1200 13-Jun-15 1430.7 1200 12-Jun-15 1400.9 1200 11-Jun-15 1333.2 1200 10-Jun-15 1233.7 1330 14-Jun-15 1490...

DateTime is not equal [duplicate]

c#,datetime
This question already has an answer here: Is there any difference between DateTime in c# and DateTime in SQL server? 3 answers I have next code: DateTime endTime = DateTime.Now.AddDays(30); InsertIntoDatabase(endTime); var row = Db.SelectRow("select endTime from MyTable Where @column=myval", columnValue); Assert.Equal(row["endTime"], endTime); // This is false! Why? Assert...

Convert long int seconds to double precision floating-point value

c++,date,datetime,time,converter
I have a long int variable wich containes seconds since Jan. 1, 1970 in this format: long int seconds = 1231241242144214; i need to convert this seconds to double precision floating-point value. The integer part of the value is the number of days since midnight, 30 December 1899. The fractional...

Addition of two dates on python 3

python,csv,datetime,python-3.x
I try adding date and hours from csv file in one datetime variable. I read questions about adding some timedelta and official doc https://docs.python.org/3/library/datetime.html#timedelta-objects, but don't understend how it works. My csv row looks like - ['2005.02.28', '17:38', '1.32690', '1.32720', '1.32680', '1.32720', '5'].I convert row[0] = 2005.02.28 to date and...

php date->foramt() return object instead of string

php,datetime,datetime-format
I want to output a date object as string using ->format() but when i return the function php automatically convert it to string? how do i prevent that? function setPassword($currOrder) { $checkInDate = $currOrder->checkInDate; // return date object $checkIndate = $checkInDate->format('j/m/Y'); print_r(gettype($checkIndate)); // output string return $checkInDate; } print_r( gettype($thisGuest->setPassword($thisOrder))...

How can I delete the '0' from my date day in django (python)?

python,django,date,datetime
I am creating a django application and I have the next problem: I have a date (for example "June 3, 2001") and I can't convert that string to date, because it doesn't exist a format directive in python to refer to a day without '0' How can I caonvert that...

Format datetime to YYYY-MM-DD HH:mm:ss in moment.js

datetime,momentjs
I have a string in this format: var dateTime = 06-17-2015 14:24:36 I am using moment.js and I am trying to convert it into YYYY-MM-DD HH:mm:ss = 2015-06-17 14:24:36. I have tried this method dateTime = moment( dateTime, 'MM-DD-YYYY HH:mm:ss',true).format("YYYY-MM-DD HH:mm:ss"); But getting dateTime as Invalid Date....

Retrieve the date portion of date object in milliseconds

javascript,date,datetime,angular-ui-bootstrap,milliseconds
How can I get the date portion of a Date object in milliseconds in javascript? I didn't find any method to this. I was trying: var today = new Date(); var datePortion = today.toDateString(); var inMiliseconds = new Date(datePortion).getMilliseconds(); console.log(inMiliseconds); The return is always 0. See jsFiddle. What can I...

display message if time difference is greater than 50 minutes - php

php,datetime,time
Basically i'm getting time difference between current time and database time. $cur_time = time(); $db_time = $rs[$k]['update_time']; $diff = abs($cur_time - $db_time); $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); $hours = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24...

Adding time/duration from CSV file

python,python-2.7,csv,datetime
I am trying to add time/duration values from a CSV file that I have but I have failed so far. Here's the sample csv that I'm trying to add up. Is getting this output possible? Output: I have been trying to add up the datetime but I always fail: finput...

Generate different period of time using joda

java,loops,datetime,iterator,jodatime
I have a scenario to generate specific time between two dates. Let's say Mar 1st to Mar 31st as my input. I need to generate datetime with specific hours as below. Mar 1st 03:00 - Mar 1st 06:59 Mar 1st 07:00 - Mar 1st 14:59 Mar 1st 15:00 - Mar...

Finding All Values in Pandas DataFrame Not of Certain Type

python,datetime,pandas
To avoid the following error, I would like to replace any integer in my DataFrame with Unix Time: ValueError: mixed datetimes and integers in passed array In a small subset of the Excel files I'm reading in, I know the integers that appear are 0. However, what if there were...

Oracle NVL function not allows second parameter as datetime

oracle,datetime,nvl
select nvl(trunc(null),trunc(sysdate)) from dual; While executing above query i am getting following error ORA-00932: inconsistent datatypes: expected NUMBER got DATE look like when i take string or number instead of trunc(sysdate) it run fine....

Dividing hh:mm:ss by an integer in Javascript

javascript,datetime
I need to split time (hh:mm:ss) by an integer. For example 13:14:24 / 12. If I convert it into date and divide: new Date( date.getMonth()+1 + " " + date.getDate() + ", " + date.getFullYear() + " " + "13:14:24") / 12; I get a really long number 119579922000, is...

Dates not recognized as Dates, despite format

excel,datetime
I have imported a column with many dates, but Excel will NOT read them as dates for some reason. I have looked around and tried doing "Text to Columns" and using "DMY" format. I have also tried simply changing the format of the cells to Date (also Custom 'dd/mm/yyyy'), but...

DateTime subtraction in ruby 2?

ruby,datetime,ruby-2.2
I need to subtract two DateTime objects in order to find out the difference in hours between them. I try to do the following: a = DateTime.new(2015, 6, 20, 16) b = DateTime.new(2015, 6, 21, 16) puts a - b I get (-1/1), the object of class Rational. So, the...

ORA-01830: date format picture ends before converting entire input string in TOAD

oracle,function,datetime,toad,to-date
I have script in which i am writing functions and procedures and the script works absolutely fine in Oracle Sql developer without any errors or warning. This script i have to provide it to client side customer. The customer user runs the same running script in TOAD and he got...

Is timezone info redundant provided that UTC timestamp is available?

datetime,time,timezone,timestamp,timestamp-with-timezone
I have a simple mobile app that schedules future events between people at a specified location. These events may be physical or virtual, so the time specified for the event may or may not be in the same timezone as the 'location' of the event. For example, a physical meeting...

Inconsistent getTimezoneOffset results

javascript,datetime
The documentation seems to suggest getTimezoneOffset() always returns the offset of the current locale, irregardless of the date object. But I'm getting inconsistent results that I can't understand. new Date().getTimezoneOffset() // -120 new Date("2015-03-10T15:48:05+01:00").getTimezoneOffset() // -60 new Date("2015-03-10T15:48:05-04:00").getTimezoneOffset() // -60 Also, is there a better way to get the timezone...

Mysql how to reduce rows by max datetime and group by non-uniqe id

mysql,datetime,join,group-by
I am having a severe case of brain flatulence. Keeping it simple, I have 3 tables: Orders, Statuses, XrefOrdersStatuses I've setup an SQLFiddle (SQLFiddle Here) with simplified schema and some redacted row data. What I need to get are Orders with their most recent XrefOrdersStatuses (joined with Statuses). I can...

Logging DateTime in SQL Table When Users Session Ends

c#,sql,session,datetime
I have written an application and with this application the user has to login. I have a table where I am keeping their login token for that session, datetime they logged in, datetime they logged out and the duration in which they were logged in. This functionality works great when...

Json String Date to date Object with angulajs Http get

json,angularjs,date,datetime,angularjs-ng-repeat
I am trying to order a list by date and popularity. From service i have a json response which has date in string format. Is it possible to change the date from Http get response to date object so that i want to use OrderBy filter to sort the list...

PHP Checking if user is online

php,date,datetime,timestamp
I don't fully understand the PHP time functions, but I'm under the impression my function should work: function user_status($timestamp){ $online = date('Y-m-d H:i:s', strtotime('-5 minutes', strtotime(date('Y-m-d H:i:s')))); $away = date('Y-m-d H:i:s', strtotime('-15 minutes', strtotime(date('Y-m-d H:i:s')))); $offline = date('Y-m-d H:i:s', strtotime('-30 minutes', strtotime(date('Y-m-d H:i:s')))); if(strtotime($timestamp) >= $online){ return 'online'; } else...

Using DateTime To Capture Upcoming Date

c#,datetime
I have this as my syntax which when I step through the code it provides the accurate date, however when I use it to create the Directory it gives me an inaccurate date (date used to create the folder is 33.22.15_Created Programmatically" DateTime upcomingMonday = DateTime.Now; while (upcomingMonday.DayOfWeek != DayOfWeek.Monday)...

Can I plot times when they're given as UNIX timestamps with added milliseconds?

datetime,gnuplot
I'm using gnuplot 4.4 on CentOS 6.6. I've found many examples online showing that the following (note the use of %.3S) will enable timestamps like "12:42:51.047" to be parsed and used as X axis values: set xdata time set format x "%H:%M:%.3S" set timefmt "%H:%M:%S" However, my input is not...

Selecting Data from Last Week in Python

python,datetime,pandas,format,dataframes
I have a large database and I am looking to read only the last week for my python code. My first problem is that the column with the received date and time is not in the format for datetime in pandas. My input (Column 15) looks like this: recvd_dttm 1/1/2015...

How to import Python modules for user in Jinja2 template

datetime,jinja2,ansible,ansible-playbook
I want to create a file name by formatting datetime.now(). It is simple enough in Python, but the datetime module needs to be imported. How can I import it for use in a Jinja2 template? For example, in this Ansible task: - name: myTask shell: echo "123" > /tmp/{{datetime.now().strftime("%Y-%m-%d_%H-%M-%S")}}.zaz ...

How get this date format CCYY-MM-DDThh:mm:ss.sss-hh:mm

c#,.net,datetime
I am expecting to pass datetime to one of the service and the format should be as "CCYY-MM-DDThh:mm:ss.sss-hh:mm". It must be datetime not string. The variable to pass in the request is like: Request.Timestamp and is Datetime. What I have tried (got exception for all of these): DateTime.Parse(DateTime.UtcNow.ToString(@"yyyy-MM-ddTHH\:mm\:ss.fffffffzzz"), null, System.Globalization.DateTimeStyles.AssumeLocal);...

C# bool statement throws strange exeption for seemingly unconnected double.parse(string)

c#,datetime,boolean
I'm an absolute begginer when it comes to C#. Trying to learn via examples. So I've found myself a nice little calculator tutorial. Everything goes fine up to last moment: code is working, but it doesn't take multidigit input like '33'. There's a bool statement there for turning arythemical operations...

pandas raises ValueError on DatetimeIndex Conversion

python,datetime,pandas
I am converting all ISO-8601 formatted values into Unix Values. For some inexplicable reason this line a_col = pd.DatetimeIndex(a_col).astype(np.int64)/10**6 raises the error ValueError: Unable to convert 0 2001-06-29 ... (Abbreviated Output of Column Name: DateCol, dtype: datetime64[ns] to datetime dtype This is very odd because I've guaranteed that each value...

DateTime Time Zone conversion bug

c#,datetime,timezone,datetime-conversion
I try to convert my local time (Kiyv, Riga, UTC+02:00) to UTC, but there is an error in the following method TimeZoneInfo.ConvertTimeToUtc(clientDate, TimeZoneInfo.FindSystemTimeZoneById(tTimeZone.SystemId)); clientDate is 19.06.2015 16:35:00 tTimeZone.SystemId is FLE Standard Time The result is 19.06.2015 13:35:00, but as I know the result should be 19.06.2015 14:35:00 Why does this...

How to change format of Date into the form 02-Jun-2015

c#,asp.net,datetime
I am filling my Grid from database. On RowEditing event I am fetching data from grid to TextBox. This is the code that I am using txtDate.Text = Convert.ToDateTime(ds.Tables[0].Rows[0]["BuyDate"]).ToShortDateString(); This gives me date in 02-06-2015 format but I want to display date in 02-Jun-2015 format....

Subtract hours from the now() function

sql,postgresql,datetime,timezone,date-arithmetic
We have a machine running 24x7. Every day I report the number of pieces it produced per hour. In our case one working day means '2015-06-16 06:00:00' to '2015-06-17 06:00:00' for example. Here is my code: select date_trunc('hour', t_el_eventlog.eventtime at time zone 'CET') as hours, count (distinct t_el_eventlog.serialnumber) as count...

How can I reliably convert YYYYMMDDhhmmss to a date/time?

sql,datetime,caché
I have a data source where the dates come back like this: 20150614140520-0500 How can I display this better? It doesn't actually have to be converted technically, this is just for reporting. Ideally it would output 2015-06-14 2:05 PM (EST) but I also want the statement to be as simple...

Check dateformat with regex in JS

javascript,regex,date,datetime
My question is simple but takes work. I tried lots of regex expressions to check my datetime is ok or not, but though I am sure my regex exprerssion is correct it always return to me isnotok with ALERT. Can you check my code? validateForLongDateTime('22-03-1981') function validateForLongDateTime(date){ var regex=new RegExp("/^\d{2}[.-/]\d{2}[.-/]\d{4}$/");...

Need a timestamp with microseconds as Decimal

python,datetime,microtime
Currently I'm using time.time() to create timestamps that include microtime. But primarily I'm comparing these against a decimal and time.time() returns a float. Currently I convert the value from float to decimal when needed: if type(stamp) == float: stamp = Decimal(format(stamp, '.15g')) But I lose some precision when doing this...

Find records between two dates not working when type is timestamp

php,mysql,sql,date,datetime
I have one table which having dates and I want to find date between two dates. For created_date table field, I have used timestamp type. Now I have created following sql query to find records between to dates like 2015-04-15 to 2015-04-21. My Table id created_date ** ******************* 10 2015-04-15...

Get max date and exact previous from max date from a given date range sql server

sql,datetime
I have date column in table ColumnName: event_timestamp 2015-06-01 15:23:31.000 2015-06-01 15:25:21.000 2015-06-03 09:00:41.000 2015-06-03 09:14:49.000 2015-06-03 09:15:03.000 2015-06-03 09:15:23.000 2015-06-06 08:40:06.000 2015-06-06 08:40:19.000 2015-06-06 11:13:35.000 2015-06-06 11:13:53.000 2015-06-06 11:15:04.000 2015-06-06 11:15:30.000 2015-06-09 15:08:13.000 2015-06-09 15:08:33.000 2015-06-09 15:08:45.000 2015-06-09 15:09:05.000 I want only 2015-06-01 2015-06-03 2015-06-06 2015-06-09 AND 2015-06-06 in...

SQL average age comparison function returns null

mysql,sql,function,datetime
So, I'm working in MySQL, writing a function that averages the ages of women and men from a table and compares them, and returns which is greater. Dates are in the format of YYYY-MM-DD, and I'm using DATEDIFF(). The function appears to work correctly, but when I run the script,...

Storing Utc Time in Getter/Setter Property

c#,asp.net,datetime
Currently, I am storing theDateTime with the DeliveryDate getter/setter. However, I'm having issues storing this in UTC time. I've done some research on this and tried DateTimeKind.Utc but can't get that to work correctly. How can I get DeliveryDate to store the DateTime in UTC time? My Code: public partial...

Parsing datetime in python json loads

javascript,python,json,datetime
I want to parse (json.loads) a json string that contains datetime values sent from a http client. I know that I can write a custom json encoder by extending the default encoder and overriding the default method class MyJSONEncoder(json.JSONEncoder): def default(self, obj): if isinstance(obj, (datetime.datetime,)): return obj.isoformat() elif isinstance(obj, (decimal.Decimal,)):...

how to convert received datetime object to timestamp in php?

php,datetime,timestamp
I receive from POST the datetime object (eg. 30/06/2015 02:04 PM). I need to use it later in my php code as a timestamp, so the variable $begin_timestamp = $_POST['date']; would contain a timestamp instead of this date time. How can I quickly change it at that point?

Python timezone offset wrong? [duplicate]

python,datetime,timezone
This question already has an answer here: pytz.astimezone not accounting for daylight savings? 1 answer I'm writing a python script which contains two lines of code converting the date that got passed into the method to UTC time: print "Timezone: %s" % get_localzone() date = datetime.now(tz=get_localzone()) print "Local time:...

extracting days between a dataframe date and today

datetime,pandas,dataframes
I have a date in a dataframe and I would like to create another dataframe column that has the number of days between this date (option expiration) and today. The date looks like this: df2.expiration.head(1) 0 05/29/15 Name: expiration, dtype: object i tried this: from datetime import datetime def compare_dates(date):...

Can someone explain this odd javascript date output?

javascript,date,datetime,time
https://jsfiddle.net/8cvhnwgs/1/ //new Date(year, month, day, hours, minutes, seconds, milliseconds) $("#out").html(new Date(2015, 5, 31, 08, 25, 30, 0)); The date I give is May 31st, but it outputs July First, can someone explain why? Have I used arguments wrong?...

problems in comparing two dates in php, minutes always 0

php,datetime,datediff
I'm gonna need to set up same date comparisons and I'm practicing first with this php code, however no matter how I alter the date I end up getting the hours and seconds but the minutes is always 0. Btw, ideally I would like to be able to write the...

SQL get row by deadline column

mysql,datetime
Say I have a table of products that looks like this: | prod_id | prod_name | prod_price | prod_deadline | | 1 | prod_A 1 | 30.00 | 2015-05-13 04:00:00| | 2 | prod_A 2 | 40.00 | 2015-06-12 04:00:00| | 3 | prod_A 3 | 50.00 | 2015-07-21 04:00:00|...

VB.Net DateTime conversion

jquery,vb.net,datetime
I have a jquery datepicker in a usercontrol. On the usercontrol i have a property that will return the selected date to the page which contains my usercontrol. I try to convert the string to a date: Dim MyDate As System.DateTime = System.Convert.ToDateTime(txtFromDateF.Value, System.Globalization.DateTimeFormatInfo.InvariantInfo) i keep getting the error: String...

Create Table - Time Statement

sql,datetime,ms-access,ddl,create-table
I am having trouble trying to create a table using MS Access. I know for sure my problem lies in the "datetime" field but I can not figure what I am missing or doing wrong. When I click "run" I get the "Syntax Error in Field Definition" Create Table Appointments...

Parsing two different formats of dates in data frame

python,parsing,datetime,pandas,dataframes
I have a column having 2 different formats of the date which I'm trying to convert to datetime using to_datetime of pandas Here's the code import pandas as pa pa.to_datetime(data["servertime"], format="%a %b %d %H:%M:%S %Y") e.g - servertime Tue Nov 4 12:01:15 2014 But few rows have data in following...

Pandas date time formatting with timezone shifting

python,datetime,pandas,timezone
I have a sqlite database where each row has a unix timestamp in EST. Changing this is not possible. I put this data into a pandas data frame. I am running a script on a server that is on UTC and when I convert the EST timestamps to date time...

ParseExact inverse my day and month

c#,datetime
my code below throw an exception as invalid date time. the error occur after i publish it to my server. working find at my developing PC string str = "27-07-2015 6:15 pm"; DateTime dt = Convert.ToDateTime(DateTime.ParseExact(str, "dd-MM-yyyy h:mm tt", null).ToString("dd-MM-yyyy hh:mm tt")); it takes '27' as month and '7' as...

How can I display a “dd/mm/yyyy” date as a “yyyy-mm-dd” date

vb.net,string,date,datetime
I keep seeing similar questions for Python and PHP, but I don't have access to those functions since I'm not using either of them. The language I'm using is VB.NET. So if I have: Dim date1 = "06/19/2015" then I want to convert it to "2015-06-19" I can replace to...

Insert date and get it in wrong format

java,sqlite,datetime,jdbc
I insert the current date in a table. I have a method to get the current datet: private static java.sql.Date getCurrentDate() { java.util.Date today = new java.util.Date(); return new java.sql.Date(today.getTime()); } Or in some cases I get the date from a from in a String format e.g. 2016-10-12 and then...

UTC Time different on servers in different timezones?

c#,sql-server,asp.net-mvc,datetime,timezone
On my dev server I save a value called "ScheduledDateUtc" date to sqlserver e.g. 24-11-14 09:00:00. I also save a value called "UtcOffset" and calculate the "ScheduledDateLocal" like so: var ScheduledDateLocal = ScheduledDateUtc.AddHours(UtcOffset); //a negative offset would be deducted and a positive offset would be added On my dev server...

Ignoring future dates in python

python,datetime,pandas,dataframes
I have a large database and I am looking to read only the last week for my python code. However, somebody made a typo in the database so there is a date in the future that is throwing everything off. Input: recvd_dttm 6/5/2015 18:28:50 PM 6/5/2015 14:25:43 PM 9/10/2015 21:45:12...

SQL Server 2008 two tables with common dates field how to select by datewise from both tables

sql-server,sql-server-2008,date,datetime
two tables with common field with dates Here i mentioned how i need output kindly any help me. table1 table1.col1 table1.col2 table1.col2 a ab 2015-05-01 00:00:00.000 as as 2015-05-01 00:00:00.000 as asasd 2015-05-01 00:00:00.000 asd aa 2015-05-02 00:00:00.000 asd asd 2015-05-04 00:00:00.000 table2 table2.col1 table2.col2 table2.col3 asd aasd 2015-05-01 00:00:00.000...

How to use varchar minus sign for mathematical operation in SQL Server 2008?

sql-server,datetime
I am trying to convert local time value to UTC value using a UTC offset value that is in a varchar(6) format. For example, "+03:30" or "-05:00" or "+08:00". I have the following SQL statement to calculate the UTC based on the UTC offset. DECLARE @d datetime = '2014-08-01 02:55:00.000'...

select specific time from diffrent dates datetime mysql field

mysql,datetime
I have a range of dates like 2015-05-31 17:36:36.000000 to 2015-12-20 22:20:00.000000. well, i want fetch rows which are between 17 and 19 of each day in that period of time. of course it is important that include minutes too. i mean, in every single day, if a row has...

How to parse non-standard month names with DateTimeFormatter

java,datetime,localization,java-8,java-time
I need to parse (German) dates that come in the following form: 10. Jan. 18:14 8. Feb. 19:02 1. Mär. 19:40 4. Apr. 18:55 2. Mai 21:55 5. Juni 08:25 5. Juli 20:09 1. Aug. 13:42 [...] As you can see, the month names are cut if the month has...

pandas parse dates from csv

parsing,datetime,pandas
I am trying to read a csv file which includes dates. The csv looks like this: h1,h2,h3,h4,h5 A,B,C,D,E,20150420 A,B,C,D,E,20150420 A,B,C,D,E,20150420 For reading the csv I use this code: df = pd.read_csv(filen, index_col=None, header=0, parse_dates=[5], date_parser=lambda t:parse(t)) The parse function looks like this: def parse(t): string_ = str(t) try: return datetime.date(int(string_[:4]),...

Extracting multiple variables from a changing string in bash

python,string,perl,date,datetime
I have multiple strings like that in a file, one per line: [random string] was [failed/passed] 1y 2mo 3d 1h 51m 2s ago [some string] Now what I want to do is extract the duration in 6 variables (years, months, days, hours, minutes, seconds) to calculate a date with the...

CakePHP Unable to insert to database (datetime format)

database,datetime,cakephp,insert
I was new to Cakephp and I actually following the tutorial of the Blog tutorial however I didn't follow their database and try my own. Currently my database: My Model: class FypCakephp extends AppModel { //Table Name public $useTable = 'Report'; public $primaryKey = 'report_id';} My Controller: public function add()...

Android unable to write datetime to sqllite database

java,android,sqlite,datetime
I'm using the Google Tasks API in my app. One of the fields in my app "due date" requires a DateTime object. Im using the Android datepicker dailog and an EditText view to capture the due date and then converting the user input into the datetime format. When I try...

How to compare sql datetime and c# datetime

c#,sql-server,datetime
This was born from my previous question I have a DateTime in c#. Then this value is inserted to database. After that select this value and compare that date is the same as it was in the beginning. What is the best way to do this? Since SQL datetime has...

Why is R (in my example) very slow for handling dates/datetimes?

r,performance,date,datetime
I have a list of 40 dataframes with about 250k rows and I want to append a new variable to each dataframes. This new variable period is calculated from another variable which contains Date objects, the transformation is very simple, if the year part of the date is lower than...

Is CurrentUICulture.DateTimeFormat different on OS and .NET version?

.net,datetime
I ran the following code on two different PC's string info = string.Format("CLR Ver. {0}, Culture Name: {1}, ShortDatePattern: {2}", Environment.Version, Thread.CurrentThread.CurrentUICulture.DisplayName, Thread.CurrentThread.CurrentUICulture.DateTimeFormat.ShortDatePattern); On a Windows Server 2008 R2 with .NET 3.5, this is the value of info CLR Ver. 2.0.50727.5485, Culture Name: English (Canada), ShortDatePattern: dd/MM/yyyy However, on a...

Identify that a string could be a datetime object

python,regex,algorithm,python-2.7,datetime
If I knew the format in which a string represents date-time information, then I can easily use datetime.datetime.strptime(s, fmt). However, without knowing the format of the string beforehand, would it be possible to determine whether a given string contains something that could be parsed as a datetime object with the...

Rails datetime_select Mongoid

ruby-on-rails,mongodb,datetime
Rails ~ 4.2.1 Mongoid ~ 4.0.2 in _form.html.erb, the code looks like this: <%= form_for @workout %> <%= f.label :date%> <%= f.datetime_select :date> <%= f.submit %> <% end %> in Workout.rb, the code looks like this: class Workout include Mongoid::Document field :date, type: DateTime end I naively thought The View...