this sounds very strange use case, but i want to update date column with some data. Please find below table. and i'm working on data which is in the JSON format.
CityName | data1 | data2 | date
Mumbai | 1.234 | 2.3456| Sat Jan 20 2018 12:00:00 GMT+0000 (UTC)
Mumbai | 6.234 | 2.3456| Sat Jan 20 2018 18:00:00 GMT+0000 (UTC)
Mumbai | 1.234 | 2.3456| Sun Jan 21 2018 12:00:00 GMT+0000 (UTC)
Mumbai | 2.234 | 2.3456| Sun Jan 21 2018 18:00:00 GMT+0000 (UTC)
Mumbai | 1.234 | 2.3456| Sun Jan 21 2018 24:00:00 GMT+0000 (UTC)
Mumbai | 1.234 | 2.3456| Sun Jan 21 2018 00:00:00 GMT+0000 (UTC)
Mumbai | 8.234 | 2.3456| Fri Jan 19 2018 01:00:00 GMT+0000 (UTC)
Mumbai | 3.334 | 2.3456| Fri Jan 19 2018 12:00:00 GMT+0000 (UTC)
Mumbai | 8.214 | 2.3456| Fri Jan 19 2018 14:00:00 GMT+0000 (UTC)
Mumbai | 19.234| 2.3456| Thu Jan 18 2018 12:00:00 GMT+0000 (UTC)
Pune | 1.234 | 2.3456| Wed Jan 17 2018 12:00:00 GMT+0000 (UTC)
Pune | 1.234 | 2.3456| Wed Jan 17 2018 12:00:00 GMT+0000 (UTC)
Pune | 1.234 | 2.3456| Sat Jan 20 2018 12:00:00 GMT+0000 (UTC)
Pune | 1.234 | 2.3456| Sat Jan 20 2018 18:00:00 GMT+0000 (UTC)
Pune | 1.234 | 2.3456| Sun Jan 21 2018 12:00:00 GMT+0000 (UTC)
Pune | 1.234 | 2.3456| Sun Jan 21 2018 18:00:00 GMT+0000 (UTC)
Pune | 1.234 | 2.3456| Sun Jan 21 2018 24:00:00 GMT+0000 (UTC)
Pune | 1.234 | 2.3456| Sun Jan 21 2018 00:00:00 GMT+0000 (UTC)
Pune | 1.234 | 2.3456| Fri Jan 19 2018 01:00:00 GMT+0000 (UTC)
Pune | 1.234 | 2.3456| Fri Jan 19 2018 12:00:00 GMT+0000 (UTC)
Pune | 1.234 | 2.3456| Fri Jan 19 2018 14:00:00 GMT+0000 (UTC)
Ahmadabad| 1.234 | 2.3456| Thu Jan 18 2018 12:00:00 GMT+0000 (UTC)
Ahmadabad| 1.234 | 2.3456| Wed Jan 17 2018 12:00:00 GMT+0000 (UTC)
Ahmadabad| 1.234 | 2.3456| Wed Jan 17 2018 12:00:00 GMT+0000 (UTC)
Now, according to city name i want to update all dates such that, s'pose today is 23rd Jul 2018 and i've selected Mumbai
, now i want first fetch all data related to selected city(e.g 'Mumbai') in descending order by date and start updating record by taking yesterday's date i.e. 22nd Jul 2018 for each 4 records in decreasing order of date, such that time stamp will be varying by 6 hours.but remaining column data should not be updated.
then for city Mumbai if I sort data in descending then i get this
Mumbai | 1.234 | 2.3456| Sun Jan 21 2018 12:00:00 GMT+0000 (UTC)
Mumbai | 2.234 | 2.3456| Sun Jan 21 2018 18:00:00 GMT+0000 (UTC)
Mumbai | 1.234 | 2.3456| Sun Jan 21 2018 24:00:00 GMT+0000 (UTC)
Mumbai | 1.234 | 2.3456| Sun Jan 21 2018 00:00:00 GMT+0000 (UTC)
Mumbai | 1.234 | 2.3456| Sat Jan 20 2018 12:00:00 GMT+0000 (UTC)
Mumbai | 6.234 | 2.3456| Sat Jan 20 2018 18:00:00 GMT+0000 (UTC)
Mumbai | 8.234 | 2.3456| Fri Jan 19 2018 01:00:00 GMT+0000 (UTC)
Mumbai | 3.334 | 2.3456| Fri Jan 19 2018 12:00:00 GMT+0000 (UTC)
Mumbai | 8.214 | 2.3456| Fri Jan 19 2018 14:00:00 GMT+0000 (UTC)
Mumbai | 19.234| 2.3456| Thu Jan 18 2018 12:00:00 GMT+0000 (UTC)
now expected o/p should be
Mumbai | 1.234 | 2.3456| Sun Jul 22 2018 00:00:00 GMT+0000 (UTC)
Mumbai | 2.234 | 2.3456| Sun Jul 22 2018 06:00:00 GMT+0000 (UTC)
Mumbai | 1.234 | 2.3456| Sun Jul 22 2018 12:00:00 GMT+0000 (UTC)
Mumbai | 1.234 | 2.3456| Sun Jul 22 2018 18:00:00 GMT+0000 (UTC)
Mumbai | 1.234 | 2.3456| Sat Jul 21 2018 00:00:00 GMT+0000 (UTC)
Mumbai | 6.234 | 2.3456| Sat Jul 21 2018 06:00:00 GMT+0000 (UTC)
Mumbai | 8.234 | 2.3456| Sat Jul 21 2018 12:00:00 GMT+0000 (UTC)
Mumbai | 3.334 | 2.3456| Sat Jul 21 2018 18:00:00 GMT+0000 (UTC)
Mumbai | 8.214 | 2.3456| Fri Jul 20 2018 00:00:00 GMT+0000 (UTC)
Mumbai | 19.234| 2.3456| Fri Jul 20 2018 06:00:00 GMT+0000 (UTC)
My other column data should not be updated, but only dates i want to update, by taking 4 records for same date but different time slot.
Or any middle ware logic will be also accepted(prefer javascript), which doesn't really update data in database but data can be manipulated in between.
Help will be appreciated....!
from want to update dates in date column, with the past dates from yesterday's date
No comments:
Post a Comment