P Peter Lewis Well-Known Member Licensed User Longtime User May 15, 2017 #1 Hi All I have looked at the jDateUtils and cannot find any process to seperate the month, day, year ect from a DateTime stamp that is stored in my sqlite database. The string is 2017-04-01 02:37:56.0 and I want to add 7 days onto it and display the result. Seems like it should be easy , I have tried all the subs and nothing gives me the answer. The closeest answer is on thread https://www.b4x.com/android/forum/threads/datetime-increment-problem.78080/#post-494792 Thank you
Hi All I have looked at the jDateUtils and cannot find any process to seperate the month, day, year ect from a DateTime stamp that is stored in my sqlite database. The string is 2017-04-01 02:37:56.0 and I want to add 7 days onto it and display the result. Seems like it should be easy , I have tried all the subs and nothing gives me the answer. The closeest answer is on thread https://www.b4x.com/android/forum/threads/datetime-increment-problem.78080/#post-494792 Thank you
EnriqueGonzalez Expert Licensed User Longtime User May 15, 2017 #2 With datetime dateformat you can change how java reads the date and time strings, pair it with the sqlite datetime stamp. Then use daytime date parse to get days and from there you can use dateutils. Upvote 0
With datetime dateformat you can change how java reads the date and time strings, pair it with the sqlite datetime stamp. Then use daytime date parse to get days and from there you can use dateutils.
A atiaust Active Member Licensed User Longtime User May 15, 2017 #3 Try this Code: Copy Dim daysDiff as int = + or - the number of days ( -7 or 7) ' Dim p As Period p.Days = daysDiff Dim newdate As Long = DateUtils.AddPeriod(DateTime.Now, p) ' Upvote 0
Try this Code: Copy Dim daysDiff as int = + or - the number of days ( -7 or 7) ' Dim p As Period p.Days = daysDiff Dim newdate As Long = DateUtils.AddPeriod(DateTime.Now, p) '
P Peter Lewis Well-Known Member Licensed User Longtime User May 15, 2017 #4 atiaust said: Try this Code: Copy Dim daysDiff as int = + or - the number of days ( -7 or 7) ' Dim p As Period p.Days = daysDiff Dim newdate As Long = DateUtils.AddPeriod(DateTime.Now, p) ' Click to expand... Thank you, I eventually did this Code: Copy DateTime.DateFormat ="yyyy-MM-dd H:m:s.S" 'initial string 2017-05-03 14:49:17.0 Dim datetick As Long = DateTime.DateParse(rowa(4)) datetick= datetick + ((86400000)*7) lbldatedue.Text=(DateTime.Date(datetick)) Upvote 0
atiaust said: Try this Code: Copy Dim daysDiff as int = + or - the number of days ( -7 or 7) ' Dim p As Period p.Days = daysDiff Dim newdate As Long = DateUtils.AddPeriod(DateTime.Now, p) ' Click to expand... Thank you, I eventually did this Code: Copy DateTime.DateFormat ="yyyy-MM-dd H:m:s.S" 'initial string 2017-05-03 14:49:17.0 Dim datetick As Long = DateTime.DateParse(rowa(4)) datetick= datetick + ((86400000)*7) lbldatedue.Text=(DateTime.Date(datetick))
Erel B4X founder Staff member Licensed User Longtime User May 15, 2017 #5 This code is wrong, it ignores the fact that there are days with 23 or 25 hours: Code: Copy datetick= datetick + ((86400000)*7) You should use DateUtils.AddPeriod. Upvote 0
This code is wrong, it ignores the fact that there are days with 23 or 25 hours: Code: Copy datetick= datetick + ((86400000)*7) You should use DateUtils.AddPeriod.
A atiaust Active Member Licensed User Longtime User May 15, 2017 #6 Like Erel says, not all days are created equal or so I fond out the hard way. Day light saving days have 25 hours when you start day light saving and 23 hours when you finish. Best use the p.days period. Upvote 0
Like Erel says, not all days are created equal or so I fond out the hard way. Day light saving days have 25 hours when you start day light saving and 23 hours when you finish. Best use the p.days period.