date

Select data within one month prior to each user's last record

喜夏-厌秋 提交于 2021-02-08 11:25:41
问题 Assume I have a table called "Diary" like this: | id | user_id | recorded_at | record | |----|---------|--------------------------|--------| | 20 | 50245 |2017-10-01 23:00:14.765366| 89 | | 21 | 50245 |2017-12-05 10:00:33.135331| 97 | | 22 | 50245 |2017-12-31 11:50:23.965134| 80 | | 23 | 76766 |2015-10-06 11:00:14.902452| 70 | | 24 | 76766 |2015-10-07 22:40:59.124553| 81 | For each user I want to retrieve the latest row and all rows within one month prior to that. In other words, for user_id

HQL query to select data between two dates not returning any record

落爺英雄遲暮 提交于 2021-02-08 11:22:49
问题 ReportView I'm getting values of Dates from JavaFX DatePicker objects tDateFrom, tDateTo. I've tried, (1) List list = session.createQuery("from ReportView where date between :stDate and :edDate") .setTimestamp("stDate", Date.from(Instant.from(tDateFrom.getValue().atStartOfDay(ZoneId.systemDefault())))) .setTimestamp("edDate", Date.from(Instant.from(tDateTo.getValue().atStartOfDay(ZoneId.systemDefault())))) .list(); (2) SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

HQL query to select data between two dates not returning any record

两盒软妹~` 提交于 2021-02-08 11:21:38
问题 ReportView I'm getting values of Dates from JavaFX DatePicker objects tDateFrom, tDateTo. I've tried, (1) List list = session.createQuery("from ReportView where date between :stDate and :edDate") .setTimestamp("stDate", Date.from(Instant.from(tDateFrom.getValue().atStartOfDay(ZoneId.systemDefault())))) .setTimestamp("edDate", Date.from(Instant.from(tDateTo.getValue().atStartOfDay(ZoneId.systemDefault())))) .list(); (2) SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

Subtract months from date in velocity

核能气质少年 提交于 2021-02-08 11:02:12
问题 I am trying to get the date a certain number of months ago from a given date I've tried converting to Calendar to then use the add method, but that didn't work: #set( $myCalendar = $date.toCalendar($endDate)) #set( $startdate = $calendarstart.add("MONTH", -$minusMonths)) I've tried to do this in a few different ways: #set( $temp = 0 - $numberOfMissedPremiums) #evaluate($calendarstart.add( 2 , $temp )) #set( $a = $calendarstart.add( 2 , $temp )) I've even tried defining blocks, but that didn't

Subtract months from date in velocity

荒凉一梦 提交于 2021-02-08 11:01:41
问题 I am trying to get the date a certain number of months ago from a given date I've tried converting to Calendar to then use the add method, but that didn't work: #set( $myCalendar = $date.toCalendar($endDate)) #set( $startdate = $calendarstart.add("MONTH", -$minusMonths)) I've tried to do this in a few different ways: #set( $temp = 0 - $numberOfMissedPremiums) #evaluate($calendarstart.add( 2 , $temp )) #set( $a = $calendarstart.add( 2 , $temp )) I've even tried defining blocks, but that didn't

SQL merging records based on date range

亡梦爱人 提交于 2021-02-08 10:54:41
问题 I have a data set representing deliveries made by several vehicles, which can each load and discharge at different locations. I am trying to find out how many vehicles it took to do all deliveries, while grouping/merging all trips that loaded within +- x days. For example: vehicle V1 could load in Zone A (date X) and B (date X+2), and discharge in Zone C and D, that would count as 1 vehicle/trip because it loaded within 2 days. V1 could also simply do Zone A (date Y) to Zone C, that would

SQL merging records based on date range

好久不见. 提交于 2021-02-08 10:52:26
问题 I have a data set representing deliveries made by several vehicles, which can each load and discharge at different locations. I am trying to find out how many vehicles it took to do all deliveries, while grouping/merging all trips that loaded within +- x days. For example: vehicle V1 could load in Zone A (date X) and B (date X+2), and discharge in Zone C and D, that would count as 1 vehicle/trip because it loaded within 2 days. V1 could also simply do Zone A (date Y) to Zone C, that would

Date Format - How to add 'n' hours to the current time in php? [duplicate]

﹥>﹥吖頭↗ 提交于 2021-02-08 10:47:20
问题 This question already has answers here : Add 'x' number of hours to date (14 answers) Closed 5 years ago . I get current time: $today = time(); $date = date('h:i:s A', strtotime($today)); How do I add 5 hours to the current time? 回答1: $today = time(); date('h:i:s A', strtotime('+5 hours'), $today); strtotime will parse any textual datetime description in English. 来源: https://stackoverflow.com/questions/31779306/date-format-how-to-add-n-hours-to-the-current-time-in-php

Date Format - How to add 'n' hours to the current time in php? [duplicate]

江枫思渺然 提交于 2021-02-08 10:45:37
问题 This question already has answers here : Add 'x' number of hours to date (14 answers) Closed 5 years ago . I get current time: $today = time(); $date = date('h:i:s A', strtotime($today)); How do I add 5 hours to the current time? 回答1: $today = time(); date('h:i:s A', strtotime('+5 hours'), $today); strtotime will parse any textual datetime description in English. 来源: https://stackoverflow.com/questions/31779306/date-format-how-to-add-n-hours-to-the-current-time-in-php

RegEx MM DD YYYY to YYYY MM DD

∥☆過路亽.° 提交于 2021-02-08 10:16:33
问题 I am new here and almost as new to RegEx. I am trying to use a RegEx expression to convert dates in a string in this format 05-18-16 or 5-18-16 or 05 18 16 or 5 18 16 to YYYY MM DD format. Note the dates in the string can be YY or YYYY. I have the "Find" expression working, but having trouble with the replacement. I found some code on this site that I thought would work, but the result is always "1900 1 31" and not 2016 05 18" Sub StackExPost() Dim strIn As String, strReturn As String strIn =