FAQ Database Discussion Community


PHP Time difference only display when not zero

php,datetime,datetime-format
I'm calculating the difference between two dates (the current date and a date in the database). I want to display the difference in days and hours between the dates, but when the day-difference is 0 I don't want to display it. This is my code: <?php $to_time = new \DateTime($database_time);...

Converting time datatype to xxhxxmxxs

postgresql,datetime-format,postgresql-8.4
I wonder if there is any function in postgres that can easily convert values stored as 00:00:00 to more human friendly format: 3h 5m ?

Input delimited is8601 datetimes in SAS

sas,datetime-format
Is it possible to input the following with a single input statement without producing any erroneous missing values? I believe I've got the right format for the first 19 characters of each of the datetime variables below, but I can't seem to find a way to make SAS ignore the...

TryParseExact failing with DateTime

c#,datetime,asp.net-mvc-5,datetime-format,tryparse
I am coding an MVC 5 internet application and I have a Bootstrap DateTimePicker control (https://github.com/Eonasdan/bootstrap-datetimepicker) to select a DateTime. Before I add the DateTime value to a model object, I use the TryParseExact function to check that the DateTime is valid. I am getting an error with the TryParseExact...

T-SQL Updated date field not the same as date format in select statement

sql-server-2008,tsql,datetime-format
In a SQL Server 2008 database I have a Fiscal Year table where the end_date for each fiscal period is set up wrong. The period start_date is the first day of a calendar month at midnight in the format smalldatetime (2015-01-01 00:00:00). The period end_date is supposed to be the...

Formatting date/time in php 4

php,string-formatting,datetime-format,php4
I'm working (or learning) on server with old php4 installed and most of the conventional methods from php5 for date/time formatting doesn't work in php4. I have time string in this format: 2003-07-23 10:15:00 Now whats the easiest way to get date separately in 23.7.2003 format and then time in...

Get original pattern String given a JDK 8 DateTimeFormatter?

java,java-8,datetime-format,java-time,jsr310
Related to my question here - how do I get the original pattern String given a DateTimeFormatter?

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 to format Date as this format 'DD.MM.Y4'?

teradata,datetime-format
I have been trying several ways to represent date as this way 10.12.2014. But I didn't find proper way to solve this problem, Teradata's FAQ gives some ways how to use FORMAT, but none how to solve my problem. So let we have SELECT DATE'2014-12-04' How can we make it...

While Loop Subtracting one month from a date to a given day

php,mysql,datetime,datetime-format
Am trying to subtract one month from a date backwards to a given date. The code i have written does the subtraction but i don't know why it doesn't complete the loop. below is the code block $date7 = date('Y-m-10'); $lastsaving = date("2013-2-9"); while($lastsaving < $date7){ $newdate = strtotime (...

Merging two columns into a single column and formatting the content to form an accurate date-time format in Hive?

sql,regex,hadoop,hive,datetime-format
these are the 2 columns(month,year). I want to create a single column out of them having an accurate date-time format('YYYY-MM-DD HH:MM:SS') and add as new column in the table. Month year 12/ 3 2013 at 8:40pm 12/ 3 2013 at 8:39pm 12/ 3 2013 at 8:39pm 12/ 3 2013 at...

Compare and filter data with date in MM/DD/YYYY format from current date using using new Date() while subtracting new Date() from user input value

javascript,angularjs,datetime-format,angularjs-filter,datetime-comparison
Trying to compare the new Date(today's date) in 2015-02-21T21:48:48.137Z format with date in MM/DD/YYYY format which is my json data. I would like to filter all the data before today's days based on user input based on number of day's user enters(getting data before no certain number of days)..I can...

Add number to the ending of a numerical date value in C#

c#,asp.net,.net,c#-4.0,datetime-format
I'm trying to store an ID with the Date (month/day/year) in the same integer value in C#. This way I can check whether a specific Id was already voted on in a particular day and prevent double voting in the same day. I store the votes in a static variable....

Save datetime in sql table

sql,sql-server,datetime,datetime-format,sqldatetime
How I can insert with a query a date like this? 2015-06-02T11:18:25.000 I have tried this: INSERT INTO TABLE (FIELD) VALUES (convert(datetime,'2015-06-02T11:18:25.000')) But I have returned: Conversion failed when converting date and/or time from character string. I tried also: CONVERT(DATETIME, '2015-06-02T11:18:25.000', 126) but it is not working: Msg 241, Level...

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 ,...

Where are the Java 8 DateTimeFormatters constants defined?

java,java-8,datetime-format,java-time,jsr310
I am looking at the DateTimeFormatter class and I was wondering where are the constants like "M", "EEE" and "YY" etc are defined. More specifically there should be code like this somewhere given a ChronoField and TextStyle, it should return the DateTimeFormatter string snippet e.g. (ChronoField.MONTH_OF_YEAR, TextStyle.SHORT) should map to...

New line in string with Date

c#,date,datetime,datetime-format
I have date in DateTime format, and I convert it to String myModel.myDateToString("dddd, d MMM 'hour.' HH:mm", myCulture); Now date in string is in one line. I want to make it like: Monday, 7 mar hour. 10:00 Is it possible ? Or I must to separate it to two objects....

DateTimeFormatter parser

java,parsing,datetime-format
I have to parse the following date: 2015-05-04 00:00:00.0 But my formatter can't recognize it. DateTimeFormatter formatter = DateTimeFormatter.ofPattern("YYYY-MM-DD HH:MM:ss.S").withLocale(Locale.US); I know it is the last character what is the problem, but don't really know what to put there....

How to get current time in a format hh:mm AM/PM in Javascript?

javascript,date,datetime,datetime-format
I have a Javascript in which I need to paste the current time in a format HH:MM AM/PM. There's one catch - I need to put the time that starts in two hours from now, so for example, instead of 7:23PM I need to put 9:23PM, etc. I tried to...

Elasticsearch cannot parse date using custom format

parsing,date,elasticsearch,jodatime,datetime-format
According to the documentation (http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/mapping-date-format.html), it should be possible to parse dates using a Joda time compatible date pattern. My data contains dates like this: "2015-02-09 02:10:05,245". These can be parsed with Joda time using the following pattern: "yyyy-MM-dd HH:mm:ss,SSS". However, when I tell my index to use this pattern...

Select from Oracle table, date time value?

php,sql,oracle,datetime-format,to-char
I want to get the date time value from oracle tables. This is my code $conn = oci_connect("xxxx", "xxxx", "xxxx"); $query_1 = "select max (p.navi_date), p.navi_user from payments p where p.pay_date >= trunc(sysdate) and p.navi_user = 'HAS:WWW:PARDOXT' group by p.navi_user order by 1"; $s_1 = oci_parse($conn, $query_1); oci_execute($s_1); //oci_fetch_all($s, $res);...

Convert date with format dd.mm.yy to yyyy-mm-dd in python

python-2.7,date,datetime-format
I have a date with format: d1 = "22.05.15" I want to change to date with format: d1 = "2015-05-22" I tried converting using datetime: d2 = datetime.strptime(d1,'%d.%m.%Y').strftime('%Y-%d-%m') But, it does not work because datetime does not support date with format '22.05.15' but only '22.05.2015' Is there any way out...

Minutes formatting issue in Query date time picker

jquery,date,jquery-plugins,datetimepicker,datetime-format
I am new to jQuery but I have been programming for more than two years in C#. I am developing a MVC project, there I have implemented a jQuery date time picker that would be used for get the user input for start date. I thought that I created the...

How to set the default value in datetimepicker as previous month

vb.net,datetime,datetimepicker,datetime-format
I have my VB.net program with a datetimepicker and the custom format of which is MM/yyyy. I want the default value at application startup in the datetimepicker as previous month and I don't care whatever day it shows(it can be any day of previous month of the same year). Using...

How do you interpret this URL time format?

xml,url,uri,datetime-format,time-format
I have rather lengthy URL that I am using in an application to receive XML data. I'd like to manipulate the time in the URL based on the users time but I don't know how to interpret it. Here's the date and time from the URL: 2015-04-27T00%3A00%3A00 My Question: Is...

Convert Y-m-d date format to d-m-Y

php,wordpress,datetime,datetime-format
I've bought a wordpress theme and one of its templates return a date in format Y-m-d. This is the code: <li><strong><?php _e("Start Date:" , SH_NAME); ?></strong><span><?php echo sh_set( $settings, 'start_date' ); ?></span></li> where 'start_date' returns Y-m-d. Please some one tell how to make 'start_date' do return m-d-Y format. Thanks....

MYSQL comparing time and day of week simultaneously

php,mysql,datetime-format
I have the following table in MYSQL database. CREATE TABLE IF NOT EXISTS `wp_my_default_settings` ( `ds_id` int(11) NOT NULL AUTO_INCREMENT, `user_id` int(11) NOT NULL, `whichday` varchar(10) NOT NULL, `tillday` varchar(10) NOT NULL, `start_time` varchar(10) NOT NULL, `end_time` varchar(10) NOT NULL, `max_no_msg` int(11) NOT NULL, `created_date` datetime NOT NULL, PRIMARY KEY...

What to modify in my query to fix literal format string error?

sql,oracle,datetime-format
Literal does not match format string select TO_DATE(TO_CHAR(A.DATE,'DD/MM/YYYY') || TO_CHAR(A.TIME),'DD/MM/YYYY HH24:MI:SS') from dual , TAB A how to modify my query so not produce the above error ? A.TIME type is varchar2(20) and A.DATE is date I also have this condition Select TO_DATE(TO_CHAR(A.DATE,'DD/MM/YYYY') || TO_CHAR(A.TIME),'DD/MM/YYYY HH24:MI:SS') < TO_DATE('20/04/2015','DD/MM/YYYY') +1 from...

Can't get date.toLocaleString() to change time to locale

javascript,date,datetime-format
I'm trying to output dates in JavaScript. The page is going to be used by folk in multiple timezones and languages to I figured it would be best to use toLocaleString(). I've tried the example from MSDN but it isn't working: var date = new Date(Date.UTC(2012, 11, 20, 3, 0,...

How can this datetime variable be converted to the string equivalent of this format in python?

python,python-2.7,datetime,datetime-format
I am using python 2.7.10 I have a datetime variable which contains 2015-03-31 21:02:36.452000. I want to convert this datetime variable into a string which looks like 31-Mar-2015 21:02:36. How can this be done in python 2.7?...

Format a posix time with just 3 digits in fractional seconds

c++,boost,time,datetime-format,time-format
What's the equivalent of microsec_clock for milliseconds in the following code? #include <boost/date_time/posix_time/posix_time.hpp> int main() { boost::posix_time::ptime date_time = boost::posix_time::microsec_clock::local_time(); const std::string str_time = boost::posix_time::to_simple_string(date_time); std::cout << str_time << std::endl; return 0; } output: 2015-Jan-25 16:26:14.932738 I need the following output: output: 2015-Jan-25 16:26:14.932 ...

Python - Convert timestamp including timezone (+0200) to humanly readable [duplicate]

python,datetime,datetime-format
This question already has an answer here: Convert weird Python date format to readable date 2 answers I can't for the life of me figure out how to convert a timestamp on the form 1433140740000+0200 to a datetime object or to any humanly readable representation. Also, what format is...

Find oldest/youngest post in mongodb collection

mongodb,datetime,aggregation-framework,datetime-format
I have a mongodb collection with many fields. One field is 'date_time', which is in an ISO datetime format, Ex: ISODate("2014-06-11T19:16:46Z"), and another field is 'name'. Given a name, how do I find out the oldest/youngest post in the collection? Ex: If there are two posts in the collection 'data'...

SimpleDateFormat and TimeZone format

java,datetime-format
I am trying to make the SimpleDateFormat class to do what I need without success. Here is the date format I need: Fri 29 May 2015 10:22:30 GMT-0400 (Eastern Daylight Time) Here is the closest format definition I was able to come with: SimpleDateFormat("EEE dd MM yyyy HH:mm:ss Z (zzzz)",...

How to set “default” AbbreviatedMonthNames? (C#)

c#,datetime-format
Is there a way of setting the default values for AbbreviatedMonthNames in C#? e.g. on MSDN, it gives the following use for the property: CultureInfo ci = CultureInfo.CreateSpecificCulture("en-US"); DateTimeFormatInfo dtfi = ci.DateTimeFormat; dtfi.AbbreviatedMonthNames = new string[] { "of Jan", "of Feb", "of Mar", "of Apr", "of May", "of Jun", "of...

C# parse 12 hours time into datetime 24 hours

c#,datetime,datetime-format
I have a list of hours which are in 12 hours format: 2:30, 3:00, 4:00, 5:00, 6:00, 7:00, 8:00, 9:00, 10:00, 11:00, 12:00, 1:00, 2:00, 3:00, 4:00, 5:00, 6:00, 7:00, 8:00, 9:00, 10:00, 11:00, 12:00, 1:00, 2:00 The first value 2:30 is in the night. If I create a List<DateTime>...

Convert a string with 'YYYYMMDDHHMMSS' format to datetime

sql-server,datetime,sql-server-2008-r2,datetime-format
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...