krlos2004 Member Licensed User Longtime User Mar 9, 2016 #1 Hello must calculate that day will be current date + 100 days I tried so but this in error, can help me? DateTime.SetTimeZone(0) DateTime.DateFormat="dd/mm/yyyy" Dim Day As Int = 100, ETicks1 As Long ETicks1 = DateTime.DateParse( "09/03/2016" ) Msgbox( DateTime.Date(ETicks1+(Day * 86400000)), "ok" ) Return 09/57/2016 ????!!!
Hello must calculate that day will be current date + 100 days I tried so but this in error, can help me? DateTime.SetTimeZone(0) DateTime.DateFormat="dd/mm/yyyy" Dim Day As Int = 100, ETicks1 As Long ETicks1 = DateTime.DateParse( "09/03/2016" ) Msgbox( DateTime.Date(ETicks1+(Day * 86400000)), "ok" ) Return 09/57/2016 ????!!!
Cableguy Expert Licensed User Longtime User Mar 9, 2016 #2 Why dont you use the TicksPerDay Dim hundreddays As Long = DateTime.TicksPerDay * 100 Dim DateInHundredDays As Long = DateTime.Date(DateTime.Now + hundreddays) Upvote 0
Why dont you use the TicksPerDay Dim hundreddays As Long = DateTime.TicksPerDay * 100 Dim DateInHundredDays As Long = DateTime.Date(DateTime.Now + hundreddays)
lemonisdead Well-Known Member Licensed User Longtime User Mar 9, 2016 #3 I would use Code: Log(DateTime.Date(DateTime.Add(DateTime.Now,0,0,100))) Upvote 0
wonder Expert Licensed User Longtime User Mar 9, 2016 #4 Code: Sub Days_to_Milliseconds(days As Int) As Long '24 * 60 * 60 * 1000 = 86400000 Return (days * 86400000) End Sub Log(DateTime.Date(DateTime.Now + Days_to_Milliseconds(100)) ...but both solutions above are way more straight forward. Upvote 0
Code: Sub Days_to_Milliseconds(days As Int) As Long '24 * 60 * 60 * 1000 = 86400000 Return (days * 86400000) End Sub Log(DateTime.Date(DateTime.Now + Days_to_Milliseconds(100)) ...but both solutions above are way more straight forward.
krlos2004 Member Licensed User Longtime User Mar 9, 2016 #5 thanks for the help,but if Ichange the day, look whathappens DateTime.DateFormat="dd/mm/yyyy" 'format brasil log( DateTime.Date(DateTime.DateParse( "01/10/2015" ) + Days_to_Milliseconds(200) ) 02/58/2015 ??? Upvote 0
thanks for the help,but if Ichange the day, look whathappens DateTime.DateFormat="dd/mm/yyyy" 'format brasil log( DateTime.Date(DateTime.DateParse( "01/10/2015" ) + Days_to_Milliseconds(200) ) 02/58/2015 ???
krlos2004 Member Licensed User Longtime User Mar 9, 2016 #6 Dim d1 As Long = DateTime.DateParse( "01/10/2015" ) Msgbox(DateTime.Date(DateTime.Add(d1,0,0,200)), "newdate" ) RETURN 20/10/2015 !!! Upvote 0
Dim d1 As Long = DateTime.DateParse( "01/10/2015" ) Msgbox(DateTime.Date(DateTime.Add(d1,0,0,200)), "newdate" ) RETURN 20/10/2015 !!!
lemonisdead Well-Known Member Licensed User Longtime User Mar 9, 2016 #7 Code: DateTime.DateFormat="MM/dd/yyyy" Dim d1 As Long = DateTime.DateParse( "01/10/2015" ) Msgbox(DateTime.Date(DateTime.Add(d1,0,0,200)), "newdate" ) Result : 07/29/2015 Code: DateTime.DateFormat="dd/MM/yyyy" Dim d1 As Long = DateTime.DateParse( "10/01/2015" ) Msgbox(DateTime.Date(DateTime.Add(d1,0,0,200)), "newdate" ) Result : 29/07/2015 Code: DateTime.DateFormat="dd/MM/yyyy" Dim d1 As Long = DateTime.DateParse( "01/10/2015" ) Msgbox(DateTime.Date(DateTime.Add(d1,0,0,200)), "newdate" ) Result : 18/04/2016 !!! Click to expand... Angry ? Last edited: Mar 9, 2016 Upvote 0
Code: DateTime.DateFormat="MM/dd/yyyy" Dim d1 As Long = DateTime.DateParse( "01/10/2015" ) Msgbox(DateTime.Date(DateTime.Add(d1,0,0,200)), "newdate" ) Result : 07/29/2015 Code: DateTime.DateFormat="dd/MM/yyyy" Dim d1 As Long = DateTime.DateParse( "10/01/2015" ) Msgbox(DateTime.Date(DateTime.Add(d1,0,0,200)), "newdate" ) Result : 29/07/2015 Code: DateTime.DateFormat="dd/MM/yyyy" Dim d1 As Long = DateTime.DateParse( "01/10/2015" ) Msgbox(DateTime.Date(DateTime.Add(d1,0,0,200)), "newdate" ) Result : 18/04/2016 !!! Click to expand... Angry ?
M Mahares Expert Licensed User Longtime User Mar 9, 2016 #8 Knowing @Erel as a big fan of DateUtils, I thought maybe I add this solution to the good solutions listed in the previous posts above: Code: Dim p As Period p.Days = 100 Dim nextdate As Long = DateUtils.AddPeriod(DateTime.DateParse("09/03/2016"), p) 'adds 100 days to this date Log($"next date: $Date{nextdate}"$) 'or Log("Next date: " & DateTime.Date(nextdate)) Upvote 0
Knowing @Erel as a big fan of DateUtils, I thought maybe I add this solution to the good solutions listed in the previous posts above: Code: Dim p As Period p.Days = 100 Dim nextdate As Long = DateUtils.AddPeriod(DateTime.DateParse("09/03/2016"), p) 'adds 100 days to this date Log($"next date: $Date{nextdate}"$) 'or Log("Next date: " & DateTime.Date(nextdate))
wonder Expert Licensed User Longtime User Mar 9, 2016 #9 Indeed, there's seems to be something broken with the DateTime parsing functions... Upvote 0
krlos2004 Member Licensed User Longtime User Mar 9, 2016 #10 putz who screwed up the error was the date format DateTime.DateFormat="dd/mm/yyyy" from DateTime.DateFormat="dd/MM/yyyy" thank's Upvote 0
putz who screwed up the error was the date format DateTime.DateFormat="dd/mm/yyyy" from DateTime.DateFormat="dd/MM/yyyy" thank's
ivan.tellez Active Member Licensed User Longtime User Mar 9, 2016 #11 krlos2004 said: putz who screwed up the error was the date format DateTime.DateFormat="dd/mm/yyyy" from DateTime.DateFormat="dd/MM/yyyy" thank's Click to expand... "mm" its for the minutes on a DateTime "MM" its for Months Upvote 0
krlos2004 said: putz who screwed up the error was the date format DateTime.DateFormat="dd/mm/yyyy" from DateTime.DateFormat="dd/MM/yyyy" thank's Click to expand... "mm" its for the minutes on a DateTime "MM" its for Months
Erel B4X founder Staff member Licensed User Longtime User Mar 10, 2016 #12 Cableguy said: Why dont you use the TicksPerDay Dim hundreddays As Long = DateTime.TicksPerDay * 100 Dim DateInHundredDays As Long = DateTime.Date(DateTime.Now + hundreddays) Click to expand... The correct way is to use DateUtils.AddPeriod. DateTime.Add is also correct in this case. The above code is incorrect and will not handle DST properly. Upvote 0
Cableguy said: Why dont you use the TicksPerDay Dim hundreddays As Long = DateTime.TicksPerDay * 100 Dim DateInHundredDays As Long = DateTime.Date(DateTime.Now + hundreddays) Click to expand... The correct way is to use DateUtils.AddPeriod. DateTime.Add is also correct in this case. The above code is incorrect and will not handle DST properly.