Search Results

Search found 15515 results on 621 pages for 'datetime format'.

Page 6/621 | < Previous Page | 2 3 4 5 6 7 8 9 10 11 12 13  | Next Page >

  • cakephp datetime insertion behaviour

    - by littlechad
    hi everyone this is a cakePHP question about datetime database insertion mismatch, i jumped in to this project while the whole thing is already built around 70%. here's what happen, every time i insert a data that contain a datetime, the inserted time doesn't match the inputted date, and the mismatch has no pattern or what ever, in some table the differences is 5 hours, while in others it could be 12 hours, 7 hours, or even 15 hours. i have traced this by investigating the controller, the model, the app_controller, everything but i don't find anything that indicate a datetime insertion rules. if the view : echo $form->input('start_date', array('label' => __l('start date')); i can't even find in the controller anything like: $this->data['current_controller']['start_date'] = $this->data['current_controller']['start_date']; when i use pr($this-data); to print the posted data, this is shown: [start_date] => Array ( [month] => 02 [day] => 16 [year] => 2011 [hour] => [min] => [meridian] => ) so i figured doing something like: $yearMonDay = $this->data['current_controller']['start_date']['year']."-"; $yearMonDay .= $this->data['current_controller']['start_date']['month']."-"; $yearMonDay .= $this->data['current_controller']['start_date']['day']; if(!empty($this->data['current_controller']['start_date']['hour'])){ $hourMinSec = $this->data['current_controller']['start_date']['hour'].":"; $hourMinSec .= $this->data['current_controller']['start_date']['min'].":"; $hourMinSec .= $this->data['current_controller']['start_date']['meridian']; }else{ $hourMinSec = "00:00:00"; } $this->data['Deal']['start_date'] = $yearMonDay." ".$hourMinSec; just to make sure the funny thing is that those posted datetime is inserted into the database with the mismatch value anyway. it's getting pretty frustrating, is there any suggestion on where else should i find the codes that define how the datetime should be inserted? or probably give me a clue on how to override those mismatched insertion rules? thanks

    Read the article

  • Proper DateTime Format for a Web Service

    - by user48408
    I have a webservice with a method which is called via a xmlhttprequest object in my javascript. The method accepts a datetime parameter which is subsequently converted to a string and run against the database to perform a calculation. I get the value from m_txtDateAdd and send off the xmlHttprequest <asp:textbox id=m_txtDateAdd tabIndex=4 runat="server" Width="96px" Text="<%# Today %>"> </asp:textbox> which has a validator attacted to it <asp:CustomValidator id="m_DateAddValidator" runat="server" ErrorMessage="Please Enter a Valid Date" ControlToValidate="m_txtDateAdd">&#x25CF;</asp:CustomValidator> My webmethod looks something like this [WebMethod] public decimal GetTotalCost(DateTime transactionDate) { String sqlDateString = transactionDate.Year+"/"+transactionDate.Month+"/"+transactionDate.Day; I use sqlDateString as part of the commandtext i send off to the database. Its a legacy application and its inline sql so I don't have the freedom to set up a stored procedure and create and assign parameters in my code behind. This works 90% of the time. The webservice is called on the onchange event of m_txtDateAdd. Every now and again the response i get from the server is System.ArgumentException: Cannot convert 25/06/2009 to System.DateTime. System.ArgumentException: Cannot convert 25/06/2009 to System.DateTime. Parameter name: type --- System.FormatException: String was not recognized as a valid DateTime. at System.DateTimeParse.Parse(String s, DateTimeFormatInfo dtfi, DateTimeStyles styles) at System.DateTime.Parse(String s, IFormatProvider provider) at System.Convert.ToDateTime(String value, IFormatProvider provider) at System.String.System.IConvertible.ToDateTime(IFormatProvider provider) at System.Convert.ChangeType(Object value, Type conversionType, IFormatProvider provider) at System.Web.Services.Protocols.ScalarFormatter.FromString(String value, Type type) --- End of inner exception stack trace --- at System.Web.Services.Protocols.ScalarFormatter.FromString(String value, Type type) at System.Web.Services.Protocols.ValueCollectionParameterReader.Read(NameValueCollection collection) at System.Web.Services.Protocols.HtmlFormParameterReader.Read(HttpRequest request) at System.Web.Services.Protocols.HttpServerProtocol.ReadParameters() at System.Web.Services.Protocols.WebServiceHandler.CoreProcessRequest()

    Read the article

  • Adjusting Timezone - Convert XML DateTime to SQL DateTime

    - by noob.spt
    We are using TypedDataSet in our application. Data is passed to procedure in form of XML for insert/update. Now after populating DE with data, datetime remains the same though timezone information is added as below. Date in DB: 2009-10-29 18:52:53.43 Date in XML: 2009-10-29T18:52:53.43-05:00 Now when I am trying to convert below XML to SQL DateTime it is adjusting 5 hours and I am getting 2009-10-29 23:52:53.430 as the final output, which is wrong. Need to find a way to extract datetime from below XML snippet ignoring timezone. I have XML in following format, with timezone difference -05.00 <Order> <EnteredDateTime>2009-10-29T18:52:53.43-05:00</EnteredDateTime> </Order>

    Read the article

  • DataTable.Select Behaves Strangely Using ISNULL Operator on NULL DateTime Column

    - by Paul Williams
    I have a DataTable with a DateTime column, "DateCol", that can be DBNull. The DataTable has one row in it with a NULL value in this column. I am trying to query rows that have either DBNull value in this column or a date that is greater than today's date. Today's date is 5/11/2010. I built a query to select the rows I want, but it did not work as expected. The query was: string query = "ISNULL(DateCol, '" + DateTime.MaxValue + "'") > "' + DateTime.Today "'" This results in the following query: "ISNULL(DateCol, '12/31/9999 11:59:59 PM') > '5/11/2010'" When I run this query, I get no results. It took me a while to figure out why. What follows is my investigation in the Visual Studio immediate window: > dt.Rows.Count 1 > dt.Rows[0]["DateCol"] {} > dt.Rows[0]["DateCol"] == DBNull.Value true > dt.Select("ISNULL(DateCol,'12/31/9999 11:59:59 PM') > '5/11/2010'").Length 0 <-- I expected 1 Trial and error showed a difference in the date checks at the following boundary: > dt.Select("ISNULL(DateCol, '12/31/9999 11:59:59 PM') > '2/1/2000'").Length 0 > dt.Select("ISNULL(DateCol, '12/31/9999 11:59:59 PM') > '1/31/2000'").Length 1 <-- this was the expected answer The query works fine if I wrap the DateTime field in # instead of quotes. > dt.Select("ISNULL(DateCol, #12/31/9999#) > #5/11/2010#").Length 1 My machine's regional settings is currently set to EN-US, and the short date format is M/d/yyyy. Why did the original query return the wrong results? Why would it work fine if the date was compared against 1/31/2000 but not against 2/1/2000?

    Read the article

  • MS SQL datetime precision problem

    - by Nailuj
    I have a situation where two persons might work on the same order (stored in an MS SQL database) from two different computers. To prevent data loss in the case where one would save his copy of the order first, and then a little later the second would save his copy and overwrite the first, I've added a check against the lastSaved field (datetime) before saving. The code looks roughly like this: private bool orderIsChangedByOtherUser(Order localOrderCopy) { // Look up fresh version of the order from the DB Order databaseOrder = orderService.GetByOrderId(localOrderCopy.Id); if (databaseOrder != null && databaseOrder.LastSaved > localOrderCopy.LastSaved) { return true; } else { return false; } } This works for most of the time, but I have found one small bug. If orderIsChangedByOtherUser returns false, the local copy will have its lastSaved updated to the current time and then be persisted to the database. The value of lastSaved in the local copy and the DB should now be the same. However, if orderIsChangedByOtherUser is run again, it sometimes returns true even though no other user has made changes to the DB. When debugging in Visual Studio, databaseOrder.LastSaved and localOrderCopy.LastSaved appear to have the same value, but when looking closer they some times differ by a few milliseconds. I found this article with a short notice on the millisecond precision for datetime in SQL: Another problem is that SQL Server stores DATETIME with a precision of 3.33 milliseconds (0. 00333 seconds). The solution I could think of for this problem, is to compare the two datetimes and consider them equal if they differ by less than say 10 milliseconds. My question to you is then: are there any better/safer ways to compare two datetime values in MS SQL to see if they are exactly the same?

    Read the article

  • Wrong date with ruby Date.today and DateTime.now

    - by Rob
    I've installed ruby-1.8.6-p383 with RVM. System ruby is 1.9.1_p378-1 I'm getting the wrong date from Date.today and DateTime.now when using ruby 1.8.. Whereas Time.now is correct: irb(main):002:0> DateTime.now.to_s => "2126--1-10618T11:23:43+00:00" irb(main):004:0> Date.today.to_s => "2126--1-10618" irb(main):005:0> Time.now => Thu Jan 28 11:55:27 +0000 2010 All is well if I switch to ruby 1.9: irb(main):003:0> DateTime.now.to_s => "2010-01-28T11:58:51+00:00" irb(main):004:0> Date.today.to_s => "2010-01-28" irb(main):005:0> Time.now => 2010-01-28 11:59:05 +0000 Any advice on how to get DateTime to work properly in ruby 1.8 would be most appreciated!

    Read the article

  • Robust DateTime parser library for .NET

    - by Frank Krueger
    Hello, I am writing an RSS and Mail reader app in C# (technically MonoTouch). I have run into the issue of parsing DateTimes. I see a lot of variance in how dates are presented in the wild and have begun writing a function like this: public static DateTime ParseTime(string timeStr) { var formats = new string[] { "ddd, d MMM yyyy H:mm:ss \"GMT+00:00\"", "d MMM yyyy H:mm:ss \"EST\"", "yyyy-MM-dd\"T\"HH:mm:ss\"Z\"", "ddd MMM d HH:mm:ss \"+0000\" yyyy", }; try { return DateTime.Parse(timeStr); } catch (Exception) { } foreach (var f in formats) { try { var t = DateTime.ParseExact(timeStr, f, CultureInfo.InvariantCulture); return t; } catch (Exception) { } } return DateTime.MinValue; } This, well, makes me sick. Three points. (1) It's silly of me to think that I can actually collect a format list that will cover everything out there. (2) It's wrong! Notice that I'm treating an EST date time as UTC (since .NET seems oblivious to time zones). (3) I don't like using exceptions for logic. I am looking for an existing library (source only please) that is known to handle a bunch of these formats. Also, I would like to keep using UTC DateTimes throughout my code so whatever library is suggested should be able to produce DateTimes. Is there anything out there like this?

    Read the article

  • perl DateTime now() problem

    - by Sergey Sinkovskiy
    Having this script use DateTime; use DateTime::Format::Strptime; my $p = DateTime::Format::Strptime->new(pattern => '%F %T', time_zone => 'local'); my $dt1 = DateTime->now(time_zone=>'local')->set_time_zone('UTC'); my $dt2 = $p->parse_datetime('2010-10-23 14:10:02')->set_time_zone('UTC'); print Dumper($dt1->hms); print Dumper($dt2->hms); print Dumper($dt1 > $dt2); The problem is that $dt1 is off by 1 hour. Like $VAR1 = '12:09:55'; $VAR1 = '11:10:02'; $VAR1 = 1; If I remove set_time_zone('UTC') in both cases - dumped values are okay. My feel is that somewhere DST is taken into account unnecessarily, but can't find out. Update: I dumped $dt-time_zone-name and $dt-offset for both and that's what i get. $VAR1 = 'Europe/Kiev'; $VAR1 = 7200; $VAR1 = 'Europe/Kiev'; $VAR1 = 10800; How this could be possible?

    Read the article

  • Joda-Time: DateTime, DateMidnight and LocalDate usage

    - by fraido
    Joda-Time library includes different datetime classes DateTime - Immutable replacement for JDK Calendar DateMidnight - Immutable class representing a date where the time is forced to midnight LocalDateTime - Immutable class representing a local date and time (no time zone) I'm wondering how are you using these classes in your Layered Applications. I see advantages in having almost all the Interfaces using LocalDateTime (at the Service Layer at least) so that my Application doesn't have to manage Timezones and can safely assume Times always in UTC. My app could then use DateTime to manage Timezones at the very beginning of the Execution's Flow. I'm also wondering in which scenario can DateMidnight be useful.

    Read the article

  • UNIX Timestamp to MySQL DATETIME

    - by Henk Denneboom
    Hi all, I have a table with statistics and a field named time with Unix Timestamps. There are about 200 rows in the table, but I would like to change the Unix timestamps to MySQL DATETIME. Without losing the current rows. What would be the best way to update the Unix Timestamp to MySQL's DATETIME? The current table: CREATE TABLE `stats` ( `id` int(11) unsigned NOT NULL auto_increment, `time` int(11) NOT NULL, `domain` varchar(40) NOT NULL, `ip` varchar(20) NOT NULL, `user_agent` varchar(255) NOT NULL, `domain_id` int(11) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 So the time (INT) should be a DATETIME field. Thanks in advance!

    Read the article

  • DateTime: Require the user to enter a time component

    - by Heinzi
    Checking if a user input is a valid date or a valid "date + time" is easy: .NET provides DateTime.TryParse (and, in addition, VB.NET provides IsDate). Now, I want to check if the user entered a date including a time component. So, when using a German locale, 31.12.2010 00:00 should be OK, but 31.12.2010 shouldn't. I know I could use DateTime.TryParseExact like this: Dim formats() As String = {"d.M.yyyy H:mm:ss", "dd.M.yyyy H:mm:ss", _ "d.MM.yyyy H:mm:ss", "d.MM.yyyy H:mm:ss", _ "d.M.yyyy H:mm", ...} Dim result = DateTime.TryParseExact(userInput, formats, _ Globalization.CultureInfo.CurrentCulture, ..., result) but then I would hard-code the German format of specifying dates (day dot month dot year), which is considered bad practice and will make trouble should we ever want to localize our application. In addition, formats would be quite a large list of all possible combinations (one digit, two digits, ...). Is there a more elegant solution?

    Read the article

  • DateTime Property not firing PropertyChanged event when changed

    - by Brent
    I'm working on a WPF MVVM application and I've got a TextBox on my view that is bound to a DateTime property on the ViewModel. Seems simple enough, but when I clear the text in the TextBox, the property never changes. In fact, it never even fires until I begin typing "4/1..." and then it fires. What can I do to fix this? Obviously I could bind the TextBox to a string property and then update the real property in the setter, but that's a bit of a hack. There's got to be a better way... ViewModel private DateTime _startDate; public DateTime StartDate { get { return _startDate; } set { _startDate = value; OnPropertyChanged("StartDate"); } } View <TextBox Text="{Binding Path=StartDate, UpdateSourceTrigger=PropertyChanged, ValidatesOnDataErrors=true}"/>

    Read the article

  • How should I check that a given argument is a datetime.date object?

    - by rmh
    I'm currently using an assert statement with isinstance. Because datetime is a subclass of date, I also need to check that it isn't an instance of datetime. Surely there's a better way? from datetime import date, datetime def some_func(arg): assert isinstance(arg, date) and not isinstance(arg, datetime),\ 'arg must be a datetime.date object' # ...

    Read the article

  • Converting datetime.ctime() values to Unicode

    - by Malcolm
    I would like to convert datetime.ctime() values to Unicode. Using Python 2.6.4 running under Windows I can set my locale to Spanish like below: import locale locale.setlocale(locale.LC_ALL, 'esp' ) Then I can pass %a, %A, %b, and %B to ctime() to get day and month names and abbreviations. import datetime dateValue = datetime.date( 2010, 5, 15 ) dayName = dateValue.strftime( '%A' ) dayName 's\xe1bado' How do I convert the 's\xe1bado' value to Unicode? Specifically what encoding do I use? I'm thinking I might do something like the following, but I'm not sure this is the right approach. codePage = locale.getdefaultlocale()[ 1 ] dayNameUnicode = unicode( dayName, codePage ) dayNameUnicode u's\xe1bado' Malcolm

    Read the article

  • setting codeigniter mysql datetime column to time() always sets it to 0

    - by Jake
    Hi guys. I'm using Codeigniter for a small project, and my model works correctly except for the dates. I have a column defined: created_at datetime not null and my model code includes in its array passed into db-insert: 'created_at' = time() This produces a datetime value of 0000-00-00 00:00:00. When I change it to: 'created_at' = "from_unixtime(" . time() . ")" it still produces the 0 datetime value. What am I doing wrong? How can I set this field to the given unix time? Also, I know mysql sets TIMESTAMP columns automatically for you - I'm not interested in that solution here. So far I can't find a complete example of this on the web.

    Read the article

  • How to represent datetime of deifferent time zomes in C#

    - by Mohoch
    Hi. I have a .NET WebService (written in C#), that is supposed to serve people around the world. With each request I get the user's datetime in his own time zone with the format : "yyyy/MM/dd HH:mm ZZZZ". I have to convert the string to something representing the original date and time and specifying the time zone in GMT. I have to make some logical calculations and keep it in the database. The regular DateTime doe's not support this. it does not have a property specifying the time zone. When I try to convert my string into DateTime - it simply converts it to my local time. I do not want to keep my time in UTC, because I have some logic that has to run per user by his own time. Does anyone know a C# class that handles this? Thanks!

    Read the article

  • how to convert server datetime to client machine datetime for the website.

    - by Shailendra
    I have datetime fieldI have datetime field into the database which stores the universal time i.e. UTC time. I want to show the datetime at the client machine in clients time zone and format. Example: Someone from US updated the database field for a site and it is stored into the UTC format. Someone from India goes and sees the site . What i want is that the person from India sees the time in IST or from Australia sees in his local machines time format not the server time format and zone. Whats the best way to do this ?? Please paste code snippet if you have. Thanx in advance!

    Read the article

  • How to represent datetime of different time zomes in C#

    - by Mohoch
    I have a .NET WebService (written in C#), that is supposed to serve people around the world. With each request I get the user's datetime in his own time zone with the format : yyyy/MM/dd HH:mm ZZZZ. I have to convert the string to something representing the original date and time and specifying the time zone in GMT. I have to make some logical calculations and keep it in the database. The regular DateTime doe's not support this. it does not have a property specifying the time zone. When I try to convert my string into DateTime - it simply converts it to my local time. I do not want to keep my time in UTC, because I have some logic that has to run per user by his own time. Does anyone know a C# class that handles this?

    Read the article

  • SQL Convert Nvarchar(255) to DateTime problem

    - by steven
    Hi, I'm using SQL server 2008. I have 2 Tables: Table 1 and Table 2. Table 1 has 1 column called: OldDate which is nvarchar(255), null Table 2 has 1 column called: NewDate which is datetime, not null Example data in Table 1: 26/07/03 NULL NULL 23/07/2003 7/26/2003 NULL 28/07/03 When i try CAST(OldDate as datetime) I get this error: Arithmetic overflow error converting expression to data type datetime. I need to insert OldDate into NewDate with no errors. I can't skip some rows. Anyhelp would be appreciated.

    Read the article

  • How does the increment operator (++) work on DateTime in C#

    - by sohtimsso1970
    What happens if you use the increment operator (++) on a DateTime type in C#? For instance, if I did this: DateTime blah = new DateTime(2010, 12, 24); blah++; What does blah become? Does that increment by a tick or a day? Or is that even legal? I don't have a dev environment around, and won't for a few days, or I would just try it and find out. I was too curious to wait so I figured I'd ask the community.

    Read the article

  • datetime.datetime.strptime problem

    - by Rahul99
    My input string is '16-MAR-2010 03:37:04' and i want to store it as datetime. I am trying to use: db_inst.HB_Create_Ship_Date = datetime.strptime(fields[7]," %d-%b-%Y %H:%M:%S ") fields[7] = '16-MAR-2010 03:37:04' I am getting an error: ::ValueError: time data '16-MAR-2010 03:37:04' does not match format ' %d-%b-%Y %H:%M:%S ' I am running Python version --EDIT-ME-- on the --EDIT-ME-- operating system. My locale is --EDIT-ME--. Which format do I have to use?

    Read the article

  • conditional selection of decimal-format in xslt

    - by Jose L Martinez-Avial
    Hi all, I'm trying to modify the decimal-format of a stylesheet based on certain information of an XML. More exaclty, I've a XML like this <?xml version="1.0" encoding="ISO-8859-1"?> <REPORT> <LANGUAGE>2</LANGUAGE> <MYVALUE>123456.78</MYVALUE> </REPORT> I'm trying to define the decimal format as european if the language is 2, and default otherwse. So I've created the following template <xsl:template match="REPORT"> <xsl:if test="$language=2"> <xsl:decimal-format decimal-separator=',' grouping-separator='.' /> </xsl:if> <xsl:value-of select ="format-number(MYVALUE,'###.###,00')"/> </xsl:template> So it shows the number in european format or in standard format. But I'm getting the following error xsl:decimal-format is not allowed in this position in the stylesheet! If I try to put the decimal-format outside the template, then I get the message that the xsl:if is not allowed in this position in the sthylsheet. How can I change the decimal-format based in the XML? Thanks Jose

    Read the article

  • SQL SERVER – DATE and TIME in SQL Server 2008

    - by pinaldave
    I was thinking about DATE and TIME datatypes in SQL Server 2008. I earlier wrote about the about best practices of the same. Recently I had written one of the script written for SQL Server 2008 had to run on SQL Server 2005 (don’t ask me why!), I had to convert the DATE and TIME datatypes to DATETIME. Let me run quick demo for the same. DECLARE @varDate AS DATE DECLARE @varTime AS TIME SET @varDate = '10/10/2010' SET @varTime = '12:12:12' SELECT CAST(@varDate AS DATETIME) C_Date SELECT CAST(@varTime AS DATETIME) C_Time As seen in example when DATE is converted to DATETIME it adds the of midnight. When TIME is converted to DATETIME it adds the date of 1900 and it is something one wants to consider if you are going to run script from SQL Server 2008 to earlier version with CONVERT. Reference: Pinal Dave (http://blog.SQLAuthority.com) Filed under: SQL, SQL Authority, SQL DateTime, SQL Query, SQL Server, SQL Tips and Tricks, T SQL, Technology

    Read the article

  • How to get the Time Difference in C# .net

    - by Aamir Hasan
    A DateTime instance stores both date and time information. The DateTime class can be found in the System namespace.In order to retrieve the current system time, we can use the static property Now of the DateTime class.In this Example i have shown, how to calculate the difference between two DateTime objects using C# syntax. DateTime startTime; DateTime endTime;            startTime = Convert.ToDateTime("12:12 AM");            endTime = Convert.ToDateTime("1:12 AM");            var timeDifference = new TimeSpan(endTime.Ticks - startTime.Ticks);Response.Write("Time difference in hours is " + timeDifference.Hours);Link:http://msdn.microsoft.com/en-us/library/8kb3ddd4.aspx

    Read the article

< Previous Page | 2 3 4 5 6 7 8 9 10 11 12 13  | Next Page >