Делаю запрос к БД postgresql. Как тогда дату необходимо написать, чтобы он за integer не считал? Почему он мне выдаёт такую ошибку:
ERROR: ОШИБКА: привести тип integer к date нельзя
LINE 3: and start_date > cast(2020-03-12 AS date)
Код
select * from contract
WHERE id = 6
and start_date > CAST(2020-03-12 AS date)
and start_date < cast(2020-03-19 as date) + interval '1' day
задан 4 окт 2020 в 21:08
Я догадался. Одинарные кавычки ведь нужно поставить, а в них дату
select * from contract
WHERE id = 6
and start_date > cast('2020-03-12' as date)
and start_date < cast('2020-03-19' as date) + interval '1' day
ответ дан 4 окт 2020 в 21:33
BlacitBlacit
1,3751 золотой знак16 серебряных знаков37 бронзовых знаков
You could convert those datetime2 fields first to datetime, then to an int.
(convert(int, convert(datetime, Setup.[Start])) - convert(int,convert(datetime, [IB].[Install_Date])))/365
But that can be shortened to:
cast(convert(datetime, Setup.[Start]) - convert(datetime, IB.[Install_Date]) as int)/365
Or you could simplify it even more and calculate the difference in years directly with datediff:
datediff(year, [IB].[Install_Date], Setup.[Start])
And that CASE can also be simplified:
case
when datediff(year, [IB].[Install_Date], Setup.[Start]) > 0
then datediff(year, [IB].[Install_Date], Setup.[Start])
else 0
end as AGE
Делаю запрос к БД postgresql. Как тогда дату необходимо написать, чтобы он за integer не считал? Почему он мне выдаёт такую ошибку:
ERROR: ОШИБКА: привести тип integer к date нельзя
LINE 3: and start_date > cast(2020-03-12 AS date)
Код
select * from contract
WHERE id = 6
and start_date > CAST(2020-03-12 AS date)
and start_date < cast(2020-03-19 as date) + interval '1' day
Ответы (1 шт):
Я догадался. Одинарные кавычки ведь нужно поставить, а в них дату
select * from contract
WHERE id = 6
and start_date > cast('2020-03-12' as date)
and start_date < cast('2020-03-19' as date) + interval '1' day
→ Ссылка
-
2
0
Votes2
Posts0
ViewsA
I recommend a dynamic table, and count, grouping for months, how many products each supplier has provided.I simulated a set of data like this: Then I created a dynamic table based on that dataset:I’ve taken the FECHA field to the row section, and I’ve grouped for months.The SUMINISTRADOR field to the column areaField ID is in the securities section, with operation RECUENTAnd I get this: Once the dynamic table is created, then you can create a dynamic chart based on that table, and with 1 click I get this: I hope it can help you.
-
2
0
Votes2
Posts0
ViewsP
Unfortunately HTML5 does not provide a way to specify a date format attribute, only the specification https://www.rfc-editor.org/rfc/rfc3339 date valid 2011-09-29.That’s why you should put the format ISO Y-m-d in your PHP to show the correct date:value=»<?PHP echo date(‘Y-m-d’,strtotime($usr->__GET(‘Fecha’))); ?>
or in your specific caseif(isset($_SESSION[«birthday_patient»])) {
$fecha = $_SESSION[«birthday_patient»];
}
value=»<?PHP echo date(‘Y-m-d’,strtotime($fecha )); ?>
Outcome: I pray that the use of this Input is still not compatible with all browsers. A viable alternative is to use a https://jqueryui.com/datepicker/ from JQuery. https://www.w3.org/TR/html-markup/input.date.html https://plus.google.com/+GoogleChromeDevelopers/posts/hTcMLVNKnec -
2
0
Votes2
Posts0
ViewsD
It seems that the function argument in this line is incorrect for error messages.sample=population.rvs(size==size)
population to define rvs() I don’t know exactly what is https://docs.scipy.org/doc/scipy-0.16.0/reference/generated/scipy.stats.rv_continuous.rvs.html ?) Optional arguments size If size=size and should be suitable.size==size and in this case True It is not quite. -
2
0
Votes2
Posts0
ViewsR
That’s how it worked:$productId = 267556;
$elementModel = new CIBlockElement();
$elementModel->SetPropertyValuesEx(
$productId,
IBLOCK_CATALOG_ID,
[‘DUMMY_UPDATED_AT’ => date(‘d.m.Y H:i:s’)]
); -
2
0
Votes2
Posts0
ViewsA
Try this:import pandas as pd
df = pd.read_csv(filename, parse_dates=[«period»])
res = (df
.assign(x=np.where(df[«recordkind»]==1, -1 * df[«points»], df[«points»]))
.groupby([pd.Grouper(key=»period», freq=»MS»), «customerid»])
[«x»]
.sum()
.reset_index(name=»points»))
In [50]: res
Out[50]:
period customerid points
0 2010-04-01 0540fe8a-c06e-42f4-8015-dd874f7ec443 48.000
1 2010-04-01 5750e29a-e783-460a-8031-30149f8e302b 1.000
2 2010-04-01 ce57503e-c1c0-476d-803e-385464dfd487 3.000
3 2010-05-01 0540fe8a-c06e-42f4-8015-dd874f7ec443 -4.020
4 2010-05-01 5750e29a-e783-460a-8031-30149f8e302b 29.368
5 2010-05-01 741912b5-583b-4785-8040-82345d8610cb 1.235 -
2
0
Votes2
Posts0
ViewsJ
Yeah, turn to the mongo documentation. Either way. update Changes only one table at the same time as SQL DB. If you want update by list key, look. https://docs.mongodb.com/manual/reference/method/db.collection.update/#examples Parameter Type Descriptionquery document Choice criteria update Same as the method. find ()♪
-
2
0
Votes2
Posts0
ViewsZ
You need a LEFT JOIN to allow you to return rows when there are no corresponding rows on a table. You also need to change WHERE to JOIN conditions.SELECT E.id_hora,
A.psb_hr,
E.fecha,
B.linea,
B.DateTime,
B.EndDate,
C.id_employee,
A.id_empatarollos,
SUM(psb_produc) AS TotalProduction,
SUM(psb_rate) AS TotalRateExpect,
SUM(scrap) AS TotalScrap,
COUNT(E.id_hora) AS FallasFTQ
FROM psb_smt.psb_produccion A
INNER JOIN psb_smt.psb_info B
ON A.id_psbinfo = B.id
INNER JOIN psb_smt.psb_employees C
ON A.id_employee = C.id_employee
INNER JOIN psb_smt.psb_employees D
ON A.id_empatarollos = D.id_employee
LEFT JOIN sisma.registroproblemaaoi E
ON A.psb_line = E.linea
AND E.fecha=’2019-09-24′
AND E.id_hora = ‘4’
WHERE A.DateTime >= ‘2019-09-24 06:40:00’ AND A.DateTime <= ‘2019-09-24 16:10:00’ AND A.psb_hr = ‘4’
GROUP by A.psb_line, E.id_hora; -
2
0
Votes2
Posts0
ViewsJ
If you store the date in the format util.Date, need to convert to type before https://docs.oracle.com/javase/8/docs/api/java/time/Instant.html , which is equivalent to util.Date in the package https://docs.oracle.com/javase/8/docs/api/java/time/package-summary.html . But as well as Date, Instant represents a point in time, but without fuse information, and to convert to LocalDate, needs that information. So you inform a https://docs.oracle.com/javase/8/docs/api/java/time/ZoneId.html (a representation of the spindle of a given region), taking the spindle of the running system, to then convert to LocalDate:Date birthday = new SimpleDateFormat(«dd/MM/yyyy»).parse(«03/09/1990»);
LocalDate ldirthday = birthday.toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
System.out.println(Period.between(ldirthday, LocalDate.now()).getYears());
Testing on the same date of publication of this response resulted in:26See working on https://ideone.com/Jedvxc .In the case of your method, it would be like this: public int idade() {
LocalDate ldirthday = meuPojo.getDataNascimento().toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
return Period.between(ldirthday, LocalDate.now()).getYears();}
I recommend reading https://pt.stackoverflow.com/a/177130/28595 about converting and using new package date classes java.time, which gives a fairly comprehensive explanation about the theme.Reference: http://www.java67.com/2016/12/best-way-to-convert-javautildate-to-javatime-LocalDate-in-Java8.html https://pt.stackoverflow.com/questions/177129/como-migrar-de-date-e-calendar-para-a-nova-api-de-datas-no-java-8 -
2
0
Votes2
Posts0
ViewsK
You can do that with the help of the additional module dblink. Install once per database (the one where the trigger is executed):
CREATE EXTENSION dblink;You need superuser privileges (in the database cluster where the trigger runs) for some of the involved functionality.
Since you want to write to the external database, you will probably want to use dblink_exec(). The manual has code examples.
Or try a search here for more dblink examples.
Note that you cannot ROLLBACK what you have written with dblink to an external database. A local exception after the external write does not undo what’s written in the foreign database. -
2
0
Votes2
Posts0
ViewsD
Right, use a parameterised request.FDQuery1.SQL.Text := ‘select * from R_Balances(:thedate’);
FDQuery1.ParamByname (‘thedate’).AsDateTime := StrToDate (Maskedit3.text);
FDQuery1.Open;
Incorrect in both other responses, including those chosen.
facepalm -
2
0
Votes2
Posts0
ViewsJ
You must get the DatePicker and he put the limits.DatePickerDialog dateDialod = new DatePickerDialog(this, oyenteSelectorFecha, anio, mes, dia);
dateDialod.getDatePicker().setMinDate(<aquí van los milisegundos de la fecha>); -
2
0
Votes2
Posts0
ViewsY
When searching for an id that does not exist it returns undefined. Add the id attribute with the respective name.<input type=»date» class=»form-control» name=»data» id=»data»>
You can search for elements by name with:$(«input[name=’nome do input’]»).val()
# is used to specify the desired element is the most specific selector.. It serves to specify one or more elements that use certain style class. -
2
0
Votes2
Posts0
ViewsS
If you specify a column should be updated then it will always be updated, but you can change the value you put in conditionally and put back the original values depending on your conditions. Something like:
UPDATE some_table
SET column_x = CASE WHEN should_update_x THEN new_value_for_x ELSE column_x END
, column_y = CASE WHEN should_update_y THEN new_value_for_y ELSE column_y END
, column_z = CASE WHEN should_update_z THEN new_value_for_z ELSE column_z END
FROM …So if the conditions are not right for an update to a particular column you just feed back it’s current value.
Do note that every row matched will see an update (even if all the columns end up getting set to the values they already have) unless you explicitly gate this circumstance in you filtering ON and WHERE clauses, which could be a performance problem (there will be a write, indexes will be updated, appropriate triggers will fire, …) if not mitigated. -
2
0
Votes2
Posts0
ViewsY
You can do your query normally, then right-click where it is marked red in the image below and save as CSV, then open the file with notepad, will be with headers and separated by «;» as below.IDT_CLIENTE;COD_COMERC;COD_FILIAL;IND_WHITE_LABEL_ATIVO
1;4236304;5556251;NULL
2;4464027;5556452;NULL
20;4261114;5556255;1
22;4236304;5556252;0
24;4503199;5556553;0 -
2
0
Votes2
Posts0
ViewsA
staff managed to tidy as I wanted to just do as follows$sql = «SELECT REPLACE(date_format(D.Mes_Ref,’%m-%y’) , ‘-‘, ‘/’ ) the Dates,this way of doing receives the D.Mes_Ref example (19/05/2016) of the bank and modifies for (05/2016) i.e. only it gets month and year.
thank you galera
Ошибка «Невозможно привести объект типа «int» к типу «java.lang.String»
Подскажите, пожалуйста, почему возникает ошибка «Невозможно привести объект типа «int» к типу «java.lang.String».
файл com/javarush/task/pro/task09/task0906/Solution.java, строка 12, позиция 321″?
package com.javarush.task.pro.task09.task0906;
import java.util.regex.Pattern;
/*
Двоичный конвертер
*/
public class Solution {
public static void main(String[] args) {
int decimalNumber = Integer.MAX_VALUE;
System.out.println(«Десятичное число » + decimalNumber + » равно двоичному числу » + toBinary(decimalNumber));
String binaryNumber = «1111111111111111111111111111111»;
System.out.println(«Двоичное число » + binaryNumber + » равно десятичному числу » + toDecimal(binaryNumber));
}
public static String toBinary(String decimalNumber) {
String binaryNumber = «»;
if (decimalNumber <= 0){
return binaryNumber;
}//напишите тут ваш код
while(decimalNumber != 0){
binaryNumber = (decimalNumber%2) +binaryNumber;
decimalNumber = decimalNumber/2;
}
return binaryNumber;
}
public static int toDecimal(int binaryNumber) {
int decimalNumber = 0;
if (binaryNumber == null || binaryNumber.equals(«»))
return 0;
for (int i = 0; i < binaryNumber.length(); i++){
int index = binaryNumber.length() — 1 — i;
int value = Character.getNumericValue(binaryNumber.charAt(index));
decimalNumber = decimalNumber + value * Math.pow(2, i);
}
//напишите тут ваш код
return decimalNumber;
}
}
Этот веб-сайт использует данные cookie, чтобы настроить персонально под вас работу сервиса. Используя веб-сайт, вы даете согласие на применение данных cookie. Больше подробностей — в нашем Пользовательском соглашении.