Posts by Paulo R. F. Amorim • 995 points
51 posts
-
0
votes2
answers108
viewsA: Handling of Javascript Dates
A way to do this is as follows: var d = new Date(2017,0,1); var year = d.getFullYear(); var month = d.getMonth(); var day = d.getDate(); var c = new Date(year + 3, month, day) // => Wed Jan 01…
-
-1
votes3
answers624
viewsA: Doubt about recursiveness in C
From what I understand of your question what you want is the following (and using recursiveness): #include <stdio.h> int somarDigitos(int valor) { if (valor == 0) return 0; else return (valor…
-
-1
votes1
answer97
viewsA: Sort text with numbers in javascript
You can do the ordering by calling the function Sort() as follows: fruits.sort(function(a, b){return Number(a.substring(a.indexOf('-')+1, a.length).trim()) < Number(b.substring(b.indexOf('-')+1,…
javascriptanswered Paulo R. F. Amorim 995 -
5
votes3
answers4373
viewsA: If H = 1 + ½ +1/3 + ¼ + ... + 1/N, make an algorithm to calculate H, where N is typed by the user
Necessary to convert into double when adding/dividing: public class MainUmSobreH { public static void main(String[] args) { double h = 0; int n = 4; for(int i=1; i<=n; i++) { h = h + (double)1/i;…
javaanswered Paulo R. F. Amorim 995 -
0
votes3
answers53
viewsA: For each value of a table show the corresponding if no zero is shown
The only way to validate whether data exists in the Passes is to use the LEFT JOIN instead of INNER JOIN.
-
0
votes1
answer132
viewsA: Merge two IF or more
You can do this using a dynamic sql: DECLARE @SQL VARCHAR(MAX) SELECT @SQL = '' IF (/*CONDICAO 1*/) BEGIN SELECT @SQL = @SQL + 'PESQUISA TRUE ' END ELSE SELECT @SQL = @SQL + 'PESQUISA FALSE ' SELECT…
-
0
votes3
answers3627
viewsA: Format a string for phone format
You can do the following, follow an example: String.Format("{0:(###) ###-####}", 8005551212); Which has as a result: (800) 555-1212
c#answered Paulo R. F. Amorim 995 -
0
votes3
answers61
viewsA: How to capture background value: url('URL') using jQuery?
It can be done as follows: var urlFoto = $("#1 > .chatImageUser").css('backgroundUrl') .replace(/.*\s?url\([\'\"]?/, '') .replace(/[\'\"]?\).*/, '');…
jqueryanswered Paulo R. F. Amorim 995 -
0
votes3
answers14733
viewsA: How to put two buttons on each other
Put this inside a table should work: <div> <table> <tr> <td> <div> <a class="button" href="(LINK)" style="float: right; border:1px solid; padding: 11px 21px;…
-
5
votes1
answer683
viewsA: Convert RGB to Hexadecimal with Javascript
One way to do this is with the following functions: function componentToHex(c) { var hex = c.toString(16); return hex.length == 1 ? "0" + hex : hex; } function rgbToHex(r, g, b) { return "#" +…
javascriptanswered Paulo R. F. Amorim 995 -
0
votes2
answers1605
viewsA: Calculate column date - 6 months of current date (SQL SERVER)
I’d do it this way: SELECT CAMPO1, CAMPO2 FROM TABELA WHERE CONVERT(SMALLDATETIME,DATEDIFF(DD,0,D_EMISSAO)) >= DATEADD(MONTH, -6, CONVERT(SMALLDATETIME,DATEDIFF(DD,0,GETDATE()))) Thus, is being…
-
10
votes3
answers9287
viewsA: Convert string to Date (dd-mm-yyyy)
You can do the following function: function toDate(dateStr) { var parts = dateStr.split("/"); return new Date(parts[2], parts[1] - 1, parts[0]); } Any further doubt or suggestion follows the link.…
javascriptanswered Paulo R. F. Amorim 995 -
0
votes4
answers4237
viewsA: Validation for Phone type field
No. The most that can be done is a Regex validating the format of the text placed on the phone. For example, this below validates the following formats with country code, DDD and phone with 8 or 9…
-
0
votes2
answers359
viewsA: Check interval between two dates
I hope this can help: var date1=new Date(2013,5,21);//Remember, months are 0 based in JS var date2=new Date(2013,9,18); var year1=date1.getFullYear(); var year2=date2.getFullYear(); var…
javascriptanswered Paulo R. F. Amorim 995 -
-1
votes3
answers1421
viewsA: Compare if two date fields are equal in C#
What you can do is simply convert the dates into format STRING for DATETIME and make a normal comparison: DateTime data1 = Convert.ToDateTime(CampoData1.text); DateTime data2 =…
-
1
votes1
answer827
viewsA: How to make a SELECT with SUM and DISTINCT?
Why not use the GROUPBY thus: SELECT conta_idconta, SUM(valor) AS ValorTotal FROM contaSaida WHERE conta_empresa_idempresa=1 AND conta_subcategoria_idsubcategoria=4 AND data BETWEEN '2017-03-06' AND…
-
0
votes1
answer231
viewsA: Javascript: Add Div by pressing a button - Typeerror: Cannot set Property 'innerHTML' of null
The problem is that at no point is the next one being added div that will be accessed. An example how to solve this is: <html> <div id="principal"> <label for="file">Envie sua…
javascriptanswered Paulo R. F. Amorim 995 -
1
votes2
answers2717
viewsA: Pick user input value with jQuery
You can do so that brings the value of the field without using the Jquery: function teste() { var nome = document.getElementById("nome").value alert(nome); }…
-
1
votes3
answers1947
viewsA: Add time column in SQL SERVER
The simplest way to do what you want is: SELECT ID, CONVERT(TIME,DATEADD (ms, SUM(DATEDIFF(MILLISECOND, 0, T)), 0)) AS TIME FROM T1 GROUP BY ID
-
1
votes1
answer40
viewsA: Jquery command does not work
The word visibility is misspelled, the correct would be: function erro(){ $("#erro").css('visibility', 'visible'); };
jqueryanswered Paulo R. F. Amorim 995 -
2
votes3
answers1407
viewsA: How to transform an Object Array into a Simple Array? Javascript
One way to do it is this: var novoArray = [] for (i = 0; i < names.length; i++) { novoArray.push(names[i].name); }
-
0
votes2
answers661
viewsA: Remove Class from a div Parent based on child element class
Try doing it this way using Jquery: $('.lazyload').parent().removeClass('image-wrap')
-
0
votes2
answers80
viewsA: Hello guys. Can anyone tell me why the result of the consultation below is bringing in the first 4 records the Zeroed Balance?
Try doing it this way: SELECT T1.Z1_COD, (SELECT ISNULL(SUM(T2.Z1_QTD),0) FROM SZ1010 T2 WHERE T1.Z1_COD=T2.Z1_COD AND T2.Z1_TPMOV = 'E' ) AS ENT, (SELECT ISNULL(SUM(T3.Z1_QTD),0) FROM SZ1010 T3…
-
2
votes1
answer846
viewsA: Configuration of the Web.Config file
What you can do is use the class Configurationmanager, adding the recipient to the web.Config as follows: <configuration> .... <appSettings> <add key="myKey" value="myValue"/>…
-
1
votes1
answer73
viewsA: How do one query depend on the result of the other?
The search should be performed as follows: SELECT T1.CAMPO1, T1.CAMPO2, T1.CAMPO3 FROM TABELA T1 WHERE T1.CAMPO2 IN (SELECT T2.CAMPO2 FROM TABELA T2 WHERE T2.CAMPO3 LIKE '%Ent%')…
mysqlanswered Paulo R. F. Amorim 995 -
1
votes2
answers572
viewsA: Get value from inside a C#string
A way VERY SIMPLE to do this is to use the replace(): Ex1 = "Aprovados por autorizantes da aplicação -> Fiscal Mestre" Ex2 = "Aprovados por autorizantes da aplicação -> Analista CAU" Ex3 =…
c#answered Paulo R. F. Amorim 995 -
2
votes2
answers21
viewsA: Swap Tag for another SQL Tag
The following must be done: UPDATE TABELA SET EMAIL = REPLACE(EMAIL,'meusite.com.br','seusite.com.br') WHERE EMAIL like '%meusite.com.br'
sqlanswered Paulo R. F. Amorim 995 -
0
votes1
answer3898
viewsA: How to generate a counter within a select (SQL server)
I’m not sure I understand the question, but that’s what you want? SELECT SUM(CASE WHEN {CONDIÇÃO VERDADEIRA} THEN 1 ELSE 0 END) AS FALTAS FROM TB_REGISTRO_PONTO…
-
1
votes1
answer1563
viewsA: Compare 2 rows of the same table
Below is an example of how it should be done: SELECT T1.PRODUTO, T1.DATA_EMISSAO, T1.DATA_VENCIMENTO FROM TABELA T1 INNER JOIN TABELA T2 ON T2.DATA_VENCIMENTO = T1.DATA_VENCIMENTO WHERE…
mysqlanswered Paulo R. F. Amorim 995 -
3
votes2
answers198
viewsA: Forcing backreference in regex
The idea of backreference in Regex is that you can reuse a block through the group created by it. For example: In that regex ([a-c])x\1x\1 is defined as group 1 the following block ([a-c]), which…
-
0
votes1
answer64
viewsA: Query return problem
The problem is that the field being grouped is not being returned in the search and also the opposite the field being returned in the search. For example the correct would be: SELECT ID,…
-
3
votes3
answers479
viewsA: Complex SQL with Mysql
I believe that’s what you want, that returns the totals for each class, grouped by the class: SELECT TI.TURMA_ID, COUNT(THE.ESTUDANTE_ID) AS TOTAL ESTUDANTES, SUM(CASE WHEN EI.SEXOID = 1 THEN 1 ELSE…
mysqlanswered Paulo R. F. Amorim 995 -
1
votes1
answer160
viewsA: Problem with full Outer Join filtering with Where
The way it is being done will not bring any name record Triple since it is not present in the availability table as it is being used the FULL OUTER JOIN, recommend to perform the survey starting at…
-
2
votes1
answer53
viewsA: Error in my query ifnull. why?
The correct thing would be to put the IFNULL(COUNT(id_rela_post), 0), instead of putting it in the search alias.
-
0
votes1
answer38
viewsQ: Doubt in SQL Performance
A question that has arisen now, and which I always see in one way or another in Sqls of procedures, is the following: NOT TABELA.CAMPO IS NULL or TABELA.CAMPO IS NOT NULL. What is the difference in…
sqlasked Paulo R. F. Amorim 995 -
0
votes1
answer29
viewsA: Select data even if it is not in all tables
What you should do is put LEFT JOIN in the tables that there is no data, example: SELECT CAMPO1, CAMPO2, CAMPO3, CAMPO4, CAMPO5, CAMPO6 FROM TABELA T1 INNER JOIN TABELA T2 ON T2.CAMPO = T1.CAMPO…
postgresqlanswered Paulo R. F. Amorim 995 -
2
votes1
answer34
viewsA: Table showing only a few columns of the database
Instead of putting, SELECT * FROM pedidos just put the following: SELECT ID, DENTISTA, CONSULTORIO, SERVICO, VALOR, MES FROM pedidos
-
1
votes2
answers81
viewsA: Table populated by other tables
From what I understand about what you want to do by example above, the way would be this is: SELECT B.CENTRO_CUSTO, SUM(A.VALOR), SUM(B.INSS + B.FGTS), SUM(C.COMISSAO + C.META + C.EXTRA) FROM…
-
1
votes3
answers1186
viewsA: How to check each character of an array? Javascript
To know if an element exists within an array or word, you can use the function indexOf() as follows: var array = [2, 5, 9]; var index = array.indexOf(5); If the value of the index variable is…
-
0
votes1
answer79
viewsA: SQL code does not work wanted an explanation of why the code error?
Apparently what you need to do is something like this: SELECT ID-ORDER, CREATEDDATE FROM ORDER WHERE DATEDIFF(DAY,CREATEDDATE,GETDATE()) < 10
sqlanswered Paulo R. F. Amorim 995 -
0
votes6
answers1028
viewsA: How to subtract an array
A simpler way to do it is, first, you should find the index of the element you want to remove: var array = [2, 5, 9]; var index = array.indexOf(5); Then you can remove the element, if found, using…
-
0
votes1
answer172
viewsA: How to Identify Carcter
Why not use the method "Trimstart(new char[] { ' ', ' n' })" and validate if the returned string is equal to the original if it is not returning the first letter? If what you want is to return the…
-
-1
votes2
answers220
viewsA: Search Dates with Difference Defined in SQL Server
The best result I can see is this:: DECLARE @IntervaloEmDias INT SELECT @IntervaloEmDias = 4 SELECT TB1.DIA FROM NOME_TABELA TB1 INNER JOIN NOME_TABELA TB2 ON TB1.DIA <> TB2.DIA WHERE…
-
1
votes1
answer81
viewsA: Aggregated function with MIN(), GROUP BY and Subquery
Try doing it this way: SELECT A.ID, A.USER_ID, A.LAT, A.LNG, DISTANCE_LATLNG_KM(X, Y, A.LAT, A.LNG) AS DISTANCE FROM ADDRESS A WHERE DISTANCE_LATLNG_KM(X, Y, A.LAT, A.LNG) = (SELECT…
mysqlanswered Paulo R. F. Amorim 995 -
1
votes2
answers85
viewsA: Inner Join - SQL Server
The right thing would be: SELECT [SemPlano].[NomeBenefTitular] AS [BenfTitularS], [ComPlano].[NomeBenefTitular] AS [BenfTitularC], [SemPlano].[NomeUsuario] AS [NomeUsuarioS],…
-
0
votes1
answer3741
viewsA: Regex Phone validation
You can use the following Regex: /^\([0-9]{2}\) [0-9]?[0-9]{4}-[0-9]{4}$/
regexanswered Paulo R. F. Amorim 995 -
-2
votes2
answers127
viewsA: Doubt in Mysql query
It does not return any result because for the examples of the past tables, I see no correlation between the related fields in the following portion of the research: INNER JOIN login lo ON…
-
0
votes2
answers413
viewsA: How to add css to all elements whose id contains "..."?
A simple way to do this, not necessarily needing to link to the element ID, would be to assign a class, and use Jquery to make the change. For example $(".classe").css(...). And this class can also…
-
-2
votes2
answers96
viewsA: Insert more than one record into a table
Mass insertion can be done by using UNION ALL as follows: INSERT INTO TableId ('Location', 'City Location') SELECT '88.064342,-50.280747','-8.77,-36.62' UNION ALL SELECT…
phpanswered Paulo R. F. Amorim 995 -
3
votes2
answers61
viewsA: Query with Internet
I believe the best way to do this would be with a subquery in condition where SQL. For example: SELECT * FROM tabela1 T1 WHERE T1.PARCELAS = (SELECT COUNT(T2.PARCELA) FROM tabela2 T2 WHERE T2.NF =…
mysqlanswered Paulo R. F. Amorim 995