w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Select Range of Datetime Records while Including Last Record Outside of Range
You can use UNION clause for the desired result: ( SELECT id, date_time FROM t1 WHERE date_time < '2013-05-31 01:15:00' ORDER BY date_time DESC LIMIT 1 ) UNION ALL ( SELECT id, date_time FROM t1 WHERE date_time BETWEEN '2013-05-31 01:15:00' AND '2013-05-31 02:20:00' );

Categories : Mysql

How to Convert Decimal to DateTime in where clause
SELECT * FROM CLBALTRNTBL WHERE LSTDAT >= convert(char(8),@sDt, 112) AND CONVERT(DATETIME,LSTDAT) <= convert(char(8),@eDt, 112) This will prevent your errors and perform faster, however your do have some invalid LSTDAT in the base that cannot be converted to dates

Categories : SQL

Datetime to decimal to pull into matplotlib with Python
If you are using python >= 2.7, you can use total_seconds: hours = td.total_seconds() / 3600 If you are using python < 2.7, you can make your own total_seconds: total_seconds = lambda td: (td.microseconds + (td.seconds + td.days * 24 * 3600) * 10**6) / 10**6

Categories : Python

ExecuteExcel4Macro to get range/charts from closed workbooks
The following bit of code pulls info from a range in a closed workbook and copies it in the same ranges in the Active Workbook: Sub GetRange() With Range("A1:D50") 'set range to copy from / to. .Formula = "='C:E3_Test[CC_Data.xlsx]AllData'!A1" 'refers to a workbook, sheet and first cell. 'It will put the relative references into the target sheet correctly. .Value = .Value 'changes formula to value. End With End Sub

Categories : Excel

cakephp getting values from fields with datatype datetime and decimal(10,0) in jquery
For range tyep use <input type="range" min="1" max="10" value="5.3" step="0.1" /> $("input[type=range]").val(); // returns 5.3 $("input[type=range]").val(6); // set value to 6 $("input[type=range]").val(); // returns 6 jQuery.val not working on range input? For datepicker http://forum.jquery.com/topic/get-the-value-from-a-datepicker-field

Categories : Jquery

mvc4 - db.SaveChanges() - decimal value out of range
Found what the deal is between these two threads: How do I prevent decimal values from being truncated to 2 places on save using the EntityFramework 4.1 CodeFirst? Entity Framework Code First: decimal precision and scale Specifically applying this code to mine: public class MyContext : DbContext { public DbSet<Metrics> Metrics { get; set; } protected override void OnModelCreating(DbModelBuilder modelBuilder) { modelBuilder.Entity<Metrics>().Property(x => x.PPM).HasPrecision(4, 3); } }

Categories : C#

Comparing a color range using either hex or decimal in javascript
I can answer #1. You can compare hexadecimal number by converting it to base of 10. Like this var h1 = "FFFF00", h2 = "FFFF01"; if (parseInt("0x" + h1, 16) < parseInt("0x" + h2, 16) ){ console.log("H1 is smaller than H2"); }

Categories : Javascript

Add two decimal digits to a number range regex
You can do this: [+-]{0,1}((?:[0-9]{1,2}|[12][0-9]{2}|3[0-5][0-9])(?:.[0-9]{1,2})?) This will allow an a decimal point followed by one or two digits. You'll probably also want to use start and end anchors (^ / $) to ensure that there are no characters other than this pattern in your string—without this, 23.333 would be allowed because 23.33 matches the above pattern: ^[+-]{0,1}((?:[0-9]{1,2}|[12][0-9]{2}|3[0-5][0-9])(?:.[0-9]{1,2})?)$ You can test it out here.

Categories : Regex

How do I calculate n averages over a datetime range?
You could create a CTE to get the intervals to group by DECLARE @numberOfIntervals INT = 3 DECLARE @startDateRange DATETIME = '2013-08-27' DECLARE @endDateRange DATETIME = '2013-08-28' -- DECLARE @range INT = DATEDIFF(HH, @startDateRange, @endDateRange) / @numberOfIntervals ;WITH calendar AS ( SELECT @startDateRange StartDate, DATEADD(HH, @range, @startDateRange) EndDate UNION ALL SELECT DATEADD(HH, @range, StartDate), DATEADD(HH, @range, EndDate) FROM calendar WHERE DATEADD(HH, @range, StartDate) < @endDateRange ) SELECT MeasurementTypeId, GeneratorId, StartDate AS MeasurementDateStart, AVG(Value) AverageValue FROM ( SELECT d.*, c.StartDate FROM data d JOIN calendar c ON d.MeasurementDate >= c.StartDate AND d.MeasurementDa

Categories : SQL

mysql datetime field with index get a range 'like' vs. 'between and' performance
Assuming that t.active_time's type is DATETIME, The following query cannot use an index because of the function call. All active_time must be converted on-the-fly to a DATE value before comparison with '2013-06-30'. This string is converted to a DATE value in the very first place, and this happens only once at the very beginning of the query. SELECT * FROM subscription t WHERE DATE(t.active_time) = '2013-06-30'; The second query cannot use an index either for similar reasons. You are actually making a string comparison (because of the LIKE operator). All active_time values are converted to a string on-the-fly. SELECT * FROM subscription t WHERE t.active_time LIKE '2013-06-30%'; Only the last one can use an index. The strings '2007-11-30' and '2007-12-01' are cast to DATETIME in this

Categories : Mysql

How to extract joda DateTime belonging to specific time range?
List<DateTime> filtered = new ArrayList<>(); for (DateTime dt : mycollection){ if (dt.getHourOfDay >= 10 && dt.getHourOfDay <= 12){ if (dt.getHourOfDay != 12 || (dt.getHourOfDay == 12 && dt.getMinuteOfHour <= 30)){ filtered.add(dt); } } }

Categories : Java

python: query a DATETIME field in a sqlite db for a date range
You can do a query like this: SELECT * FROM Table where date >= date('now', '-60 day'); EDIT: Based on your actual query: select <field1>, <field2>, count(1) as num FROM Table where date >= date('now', '-60 day'); group by <field1>, <field2>; SELECT DISTINCT is unnecessary when you are using GROUP BY.

Categories : Python

Get range of columns from Cassandra based on TimeUUIDType using Python and the datetime module
You do want to request a "slice" of columns using the column_start and column_finish parameters to get(), multiget(), get_count(), get_range(), etc. For TimeUUIDType comparators, pycassa actually accepts datetime instances or timestamps for those two parameters; it will internally convert them to a TimeUUID-like form with a matching timestamp component. There's a section of the documentation dedicated to working with TimeUUIDs that provides more details. For example, I would implement your function like this: def get_number_of_visitors(site, start_date, end_date=None): """ start_date and end_date should be datetime.datetime instances or timestamps like those returned from time.time(). """ if end_date is None: end_date = datetime.datetime.now() pool = Con

Categories : Python

Drop extraneous decimal places when using Python's decimal.Decimal
Use Decimal.normalize: >>> Decimal('0.00').normalize() Decimal('0') >>> Decimal('0.50').normalize() Decimal('0.5')

Categories : Python

SQL server 2012: Cast a varchar (255) column to datetime results to an out-of-range value error
There are many string formats supported by SQL Server - see the MSDN Books Online on CAST and CONVERT. Most of those formats are dependent on what language / dateformat settings you have - therefore, these settings might work some times - and sometimes not. The way to solve this is to use the (slightly adapted) ISO-8601 date format that is supported by SQL Server - this format works always - regardless of your SQL Server language and dateformat settings. The ISO-8601 format is supported by SQL Server comes in two flavors: YYYYMMDD for just dates (no time portion); note here: no dashes!, that's very important! YYYY-MM-DD is NOT independent of the dateformat settings in your SQL Server and will NOT work in all situations! or: YYYY-MM-DDTHH:MM:SS for dates and times - note here: this

Categories : Sql Server

How do I handle "out of range" warnings for timezone-aware datetime objects on MySQL with and without SQLAlchemy
Without SQLAlchemy the answer is basically already in the question: Make it naive but in such a way that you always store the same (read: UTC) timezone: if now.tzinfo is not None: now = now.astimezone(utc).replace(tzinfo=None) return now This will make sure that UTC is always stored (but if passing naive make sure that it is always naive! And when pulling the item out of the database, make sure to make it UTC-aware again: if created_at.tzinfo is None: created_at = utc.localize(created_at) return created_at Since MySQL is not capable of tz-aware objects, the check could be removed (it should always be None). For SQLAlchemy, the same approach can be used (but with the extension of letting SA do it automatically). For this we use the TypeDecorator: class TZDateTime(TypeDecorat

Categories : Python

how to do globalization in a website mvc 4
look here: http://www.nuget.org/packages/Code52.i18n.MVC4 and here http://code52.org/aspnet-internationalization/tutorial.html for the tutorial. It may help to give you a start.

Categories : Asp Net Mvc

Jquery Globalization
The jQuery globalization plugin from Microsoft has been accepted as a offical jQuery plugin a couple of years ago (http://blog.jquery.com/2010/10/04/new-official-jquery-plugins-provide-templating-data-linking-and-globalization/) You can find the latest version here along with examples: https://github.com/jquery/globalize. A more complete example of your code is needed to see why you get the error you get. Try to show it on http://jsfiddle.net/ maybee?

Categories : Jquery

RichTextBox Globalization
I think I am going to ask the user for his desired Rtf (supplied by his local OS RichTextBox) to use as when creating the new record. Then just assume it is empty and tack on my stuff at the end.

Categories : Dotnet

How do I Implement Globalization and Localization in ASP.NET
Your question should provide more detail and describe what you have already tried. The best/easiest way is javascript - good option that leads to what I might guess is a middle ground for you here: How to get client date and time in ASP.NET? If you don't want to use javascript you can try and determine it from the request headers, but this is less likely to consistently work. Found this in an answer that strangely also linked the first link above: http://weblogs.asp.net/mikebosch/archive/2007/11/15/getting-the-client-browsers-date-and-time-with-asp-net.aspx

Categories : Asp Net

Why method now in Python is obtained as datetime.datetime.now instead of datetime.time.now?
"Now" is a point in time. That means date matters; if it's noon now, yesterday noon is not also now. (Time of day also matters; 9 AM today is also not now.) Thus, it makes sense to have a datetime.datetime.now, but not a datetime.time.now. It could make sense to have a datetime.time.currentlocaltime or datetime.time.currentutctime, but those methods don't exist. You could put in a feature request if you want.

Categories : Python

Finalizing a Cursor that has not been deactivated or closed or database not closed error
When you are done with the cursor, you need to call Cursor.close(). Leaving it not closed leads to memory leaks. E.g.: Cursor cursor = null; try { cursor = getContentResolver().query(myUri, MY_PROJECTION, null, null, null); if (cursor != null && cursor.moveToFirst()) { // moar code } } finally { if (cursor != null) { cursor.close(); } }

Categories : Android

Globalization of controller names and actions
Please ignore this question. I just found the answer on http://blog.maartenballiauw.be/post/2010/01/26/Translating-routes-(ASPNET-MVC-and-Webforms).aspx

Categories : Asp Net

Globalization .net convert string to double
Try this: var res = Double.Parse("65.50", NumberStyles.Float, CultureInfo.InvariantCulture); It will parse it with culture where . is floating separator Here you can try it: http://ideone.com/3LMVqa

Categories : C#

globalization in web.config missing after publish
Can you check to see if you have a transformation in the release/publish config file that might be removing this item? You probably have something in web.Publish.config. NOTE: You'll need to have 'Show all files' turned on to see the transformation files.

Categories : Asp Net Mvc

Globalization is undefined and onPhoneGapAvailable doesn't fire
I've never used gwtphonegap so I don't know how initializePhoneGap works neither the onPhoneGapAvailable event, but I'm sure that document.addEventListener("deviceready", (function(){ PhoneGap.available = true;}), false); fires once cordova has fully loaded, so in your case PhoneGap.available = true; when your device is ready. Maybe you have to check that PhoneGap.available is true instead of counting on onPhoneGapAvailable event.

Categories : Gwt

Exception in assigning to CurrencyDecimalDigits in Globalization.NumberFormatInfo
Found the solution, NumberFormatInfo is read only, therefore need to call clone() method when assigning to it:Dim a As Globalization.NumberFormatInfo a = New Globalization.NumberFormatInfo() a = a.Clone() Dim b As Integer = 4 a.CurrencyDecimalDigits = b

Categories : Vb.Net

Application gets closed when terminal is closed, how to stop this?
Use nohup to prevent child processes from being killed when the terminal closes. spawn nohup /usr/bin/firefox https://www.google.com/ I assume there's more to the script, since there's no need to use Expect just to start firefox.

Categories : Python

System.Globalization.DateTimeFormatInfo returns the same format in all languages?
For safety AND readability, you can always do this: [System.Globalization.DateTimeFormatInfo]::CurrentInfo.AbbreviatedDayNames[[DayOfWeek]::Sunday] Related: Getting a short day name

Categories : Powershell

string is not supported in calendar System.Globalization.GregorianCalendar
If you want to alter the format of a column of a GridView from CodeBehind Add a RowDataBound to your grid view. Then in the GridView_RowDataBound(object sender, GridViewRowEventArgs e) method, you'll be able to access e which will provide you with access to the individual cells of that row where you can specify a format. Reference Reference2

Categories : Asp Net

Dynamically declare System.Globalization Calendars in a function?
SOLVED. I don't know if this is the easiest way...but here is the final code that work. Public Function GetDaysInMonth(ByVal dt As Date, Optional ByVal sCalendar As String = "GREGORIAN") As Integer System.Globalization.CultureInfo.InvariantCulture Dim cal As System.Globalization.GregorianCalendar Dim y, m As Integer y = Year(dt) m = Month(dt) Select Case UCase(sCalendar) Case "HEBREW" Dim cal1 As New HebrewCalendar Return (cal1.GetDaysInMonth(y, m)) Case "HIJRI" Dim cal2 As New HijriCalendar Return (cal2.GetDaysInMonth(y, m)) Case "JAPENESE" Dim cal3 As New JapaneseCalendar Return

Categories : Asp Net

jQuery Globalization. Pass currency unit as argument for C format
The only documented way to modify the currency symbol in Globalize is to change the numberFormat.currency.symbol property of a given culture—in this case, the fr-FR culture. This will kind of do what you want, but it’s not a very elegant solution, and you would need to manually build a table of correct symbols for each locale and write another method to swap them out. (n.b. It is possible to pass a third argument to Globalize.format with a different locale identifier, but this just formats the number using that locale’s cultural settings.) Looking at the culture definition syntax, there is simply no provision for displaying different currencies using a given locale. If you were to look elsewhere, the dojo/currency module in the Dojo Toolkit does do exactly what you need, using data

Categories : Javascript

Need to return a date/time string from phonegap's navigator.globalization.dateToString
Yes it's an asynchronous call so you need to continue your process in the callback function : var myTime = new Date(parseInt(myData.StartTime.substr(6))); // get a date object var myTimeString = ''; console.log("before"); navigator.globalization.dateToString(myTime, function(date) { console.log("doing"); myTimeString = date.value; callback(myTimeString); }, function() { alert('Error getting dateString '); }, { formatLength : 'short', selector : 'date and time' }); function callback(myTime) { console.log("done"); console.log(myTime); }

Categories : Javascript

Reading an Excel File (Excelfinlename.dvd) with decimal comma instaed of decimal point?
By using only Matlab: you could try to use the raw-output and replace comma with dot. You get the raw data as the third output of xlsread: [num,txt,raw] = xlsread(_) additionally returns the text fields in cell array txt, and the unprocessed data (numbers and text) in cell array raw using any of the input arguments in the previous syntaxes. If xlRange is specified, leading blank rows and columns in the worksheet that precede rows and columns with data are returned in raw. What would be better in my opinion, is to change comma to dot within Excel. At the moment, matlab (or xlsread) is interpreting the data as something else.

Categories : Matlab

Access adding column of type decimal(number with fieldsize decimal)
Your query looks fine. The decimal data type isn't supported in the default Jet 4.0 mdb file. You have to use the SQL Server compatibility syntax (ANSI 92) setting to use the decimal data type in the SQL Window. Click on the menu, Tools > Options. Click on the Tables/Query tab. Mark the check box for "This database" in the SQL Server compatibility syntax (ANSI 92) section. This mode will affect the entire db, including queries with wildcards, so you may want to try this on a copy of your db

Categories : SQL

Formatting a decimal value with ToString() to have commas as thousand separators where the amount of decimal places is unknown
Try using Format. double d = 1.234567; String output = d.ToString("#,##0.##"); Also, double d = 123456789.1; string format = d.ToString(). IndexOf(NumberFormatInfo.CurrentInfo.NumberDecimalSeparator) >=0 ? "#,##0.00" : "#,##0"; Console.WriteLine (d.ToString(format));

Categories : C#

SQL Server - Convert decimal to string with padding - implied decimal
Maybe the following sql code will be useful: SELECT CASE WHEN NUMBER < 100 THEN RIGHT('0000' + CAST(CAST(NUMBER AS INT) AS VARCHAR),4) ELSE RIGHT(SUBSTRING(CAST(NUMBER AS VARCHAR),1,CHARINDEX('.',CAST(NUMBER AS VARCHAR))-1),4) + LEFT(PARSENAME(NUMBER,1),1) END RESULT FROM TEST You can try this here sqlfiddle. Note: NUMBER is your field, and TEST is your TABLE.

Categories : SQL

Precisely multiplying 100,000 decimal digits using decimal module in python
I think that your problem is that you are either saving x in a string and re-interpreting in or you have x from a previous calculation as a Decimal and you are doing Decimal(A_Decimal). If x is already a decimal then do not reinterpret it and if to save time you are saving if then use pickle or cpickle to save it as an object. BTW try to avoid import * - use namespaces. BTW be sure and set the current precision before importing x from anywhere!

Categories : Python

How can a decimal format to string in mvc avoiding the last two zero s after the decimal point in mvc3
You can create Helper method e.g. DisplayDecimal public static class HtmlExtensionsView { public static string DisplayDecimal(this HtmlHelper helper, decimal? input) { // you can do you rouding math here } } then in your .cshtml file you can call (referencing extension's namespace) @Html.DisplayDecimal(modelItem => item.LoanAmount) More information about rounding in C# is available at http://msdn.microsoft.com/en-us/library/3s2d3xkk.aspx

Categories : Asp Net Mvc

Converting Decimal BGR color to individual RGB decimal values
One of my first languages was C, and the following would be a fairly trivial macro. color = ((color & 0xff0000) >> 16) | (color & 0x00ff00) | ((color & 0x0000ff) << 16) Put this inside a bgr_to_rgb method and forget about it. There is no need to reach for #to_s or #hex. To get the individual R, G, B values from a BGR code, use red = color & 0x0000ff green = color & 0x00ff00 blue = color & 0xff0000

Categories : Ruby On Rails



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.