There is a java web site, jQuery datepicker is attached to the form. For sampling from the database, you need to compare 2 dates, or rather, there is a transition from one day to another, for example, there is a certain change 1 (its time is from 22-00 01/01/2016 to 7-00 02.01.2016).

On the form for displaying the report, you can choose absolutely any date and year, but if it is a shift 1, then you need to use the date of the next day instead of the current date.

How to implement it correctly? Change is defined as:

if (gang.equals("1")){time_start = "22:00:00"; time_end = "7:00:00";} 

    1 answer 1

    To get the date value in js for a day more (make a conclusion from the topic of the question) than the available value, it is enough to do this:

     // date - какая-то имеющаяся дата date.setDate(date.getDate() + 1) //если дата на стыке месяца, все равно корректно рассчитается браузером 

    In Java, as far as I can tell from the documentation, it should work:

     //date - инстанс java.util.Calendar date.add(Calendar.DAY_OF_MONTH, 1); 

    In Oracle, if the DATE type is used, it suffices to make date + 1 , which will give the date following the date .

    In general, such things, it seems to me, it is better to do in the database when requesting a report.

    Because in the database, there should still be shift identifiers, or information about which shift works at night, and also, to build a report, you need to send some group identifier to the procedure, then it’s logical in the report building procedure to check that if the shift is working at the junction of dates - check for a day more (roughly speaking).

    • <script type = "text / javascript"> $ (document). ready (function () {$ ("# datepicker"). datepicker ({dateFormat: "dd.mm.yy"}); date.setDate (date. getDate () +1)}); </ script> So? - Ethernets
    • Well, if it is better to choose everything through the database, how can I determine the starting date and the final one? please share - Ethernets
    • in the code given in the commentary, you do not verify that this is the first shift, and you also never get the date in the date variable. - NumminorihSF
    • Thanks for the thought, solved the problem by requesting a database. - Ethernets