H hackhack Active Member Licensed User Longtime User Jun 27, 2011 #1 Ok, I have DateTime.Now and SomeFutureDate - if I quickly wish to display the difference between now and future as days/hours/months/seconds - is there a quick way to do that I overlooked? For a brief moment i thought perhaps i could subtract the future long with the current long and do datetime routines on them, but that ended up total nonsense
Ok, I have DateTime.Now and SomeFutureDate - if I quickly wish to display the difference between now and future as days/hours/months/seconds - is there a quick way to do that I overlooked? For a brief moment i thought perhaps i could subtract the future long with the current long and do datetime routines on them, but that ended up total nonsense
kanaida Active Member Licensed User Longtime User Jun 28, 2011 #2 I know it's wierd dealing with ticks lol I was trying to make a stopwatch and did this: Start = DateTime.Now End = DateTime.Now TimeTaken = End - Start ??? Profit! lol I think you can try: TimeTaken / DateTime.TicksPerDay. that should give you How many days difference I think. More than that, there really should be a Date/DateTime Class that handles dates in english. Last edited: Jun 28, 2011 Upvote 0
I know it's wierd dealing with ticks lol I was trying to make a stopwatch and did this: Start = DateTime.Now End = DateTime.Now TimeTaken = End - Start ??? Profit! lol I think you can try: TimeTaken / DateTime.TicksPerDay. that should give you How many days difference I think. More than that, there really should be a Date/DateTime Class that handles dates in english.
Erel B4X founder Staff member Licensed User Longtime User Jun 28, 2011 #3 TimeTaken / DateTime.TicksPerDay Click to expand... The above suggestion is correct. Make sure to declare the variables holding tick values as longs. Upvote 0
TimeTaken / DateTime.TicksPerDay Click to expand... The above suggestion is correct. Make sure to declare the variables holding tick values as longs.
H hackhack Active Member Licensed User Longtime User Jun 28, 2011 #4 Yeah, but as I said I need days/hours/months/seconds - and i tried it and it didn't work. Upvote 0
Erel B4X founder Staff member Licensed User Longtime User Jun 28, 2011 #5 It should work. If you like you can post your code and we will help you fix it. Upvote 0
H hackhack Active Member Licensed User Longtime User Jun 28, 2011 #6 Thanks, but I erased it when it didn't work. However I may redo it later However, you are saying that one can't use datetime functions to extract day/hour/minute after subtracting the time amount? Upvote 0
Thanks, but I erased it when it didn't work. However I may redo it later However, you are saying that one can't use datetime functions to extract day/hour/minute after subtracting the time amount?
Erel B4X founder Staff member Licensed User Longtime User Jun 28, 2011 #7 First make sure to work with Long variables. You can use those functions with any value. A ticks value represents the number of milliseconds passed since 1/1/1970. I do not know whether it is useful or not in your case. Upvote 0
First make sure to work with Long variables. You can use those functions with any value. A ticks value represents the number of milliseconds passed since 1/1/1970. I do not know whether it is useful or not in your case.
H hackhack Active Member Licensed User Longtime User Jun 29, 2011 #8 Also, is it possible to generate a complete time point? This Code: Copy DateTime.DateParse("07/07/2011 06:00:00") Doesn't seem to work, the time is set to 00:00:00 Code: Copy DateTime.DateParse("07/07/2011") + DateTime.TimeParse("06:00:00") Doesn't work either, the time is 6, but its sometime decades in the future - not surprising since the docs say that timeparse adds "today" to the value returned . Can one AND out the date value of the timeparse result and OR it with the dateparse result? Or is there another option? Upvote 0
Also, is it possible to generate a complete time point? This Code: Copy DateTime.DateParse("07/07/2011 06:00:00") Doesn't seem to work, the time is set to 00:00:00 Code: Copy DateTime.DateParse("07/07/2011") + DateTime.TimeParse("06:00:00") Doesn't work either, the time is 6, but its sometime decades in the future - not surprising since the docs say that timeparse adds "today" to the value returned . Can one AND out the date value of the timeparse result and OR it with the dateparse result? Or is there another option?
S SteveBee Member Licensed User Longtime User Jun 29, 2011 #9 You should ensure to set the *format* before you attempt to parse: e.g. Code: Copy .... Dim DT As Long DateTime.DateFormat = "yyyy-MM-dd'T'HH:mm:ss" DT = DateTime.DateParse(Attributes.GetValue(i)) DateTime.DateFormat = "dd-MMM-yyyy HH:mm" lblSchedStart.Text = DateTime.Date(DT) .... Upvote 0
You should ensure to set the *format* before you attempt to parse: e.g. Code: Copy .... Dim DT As Long DateTime.DateFormat = "yyyy-MM-dd'T'HH:mm:ss" DT = DateTime.DateParse(Attributes.GetValue(i)) DateTime.DateFormat = "dd-MMM-yyyy HH:mm" lblSchedStart.Text = DateTime.Date(DT) ....
H hackhack Active Member Licensed User Longtime User Jun 29, 2011 #10 SteveBee said: You should ensure to set the *format* before you attempt to parse: e.g. Code: Copy .... Dim DT As Long DateTime.DateFormat = "yyyy-MM-dd'T'HH:mm:ss" DT = DateTime.DateParse(Attributes.GetValue(i)) DateTime.DateFormat = "dd-MMM-yyyy HH:mm" lblSchedStart.Text = DateTime.Date(DT) .... Click to expand... Wait what, Attributes.GetValue? What's that returning I thought that was related to xml? Or is it just an example? Also, dateformat can include the time? (Docs didn't say) - that may change things. Upvote 0
SteveBee said: You should ensure to set the *format* before you attempt to parse: e.g. Code: Copy .... Dim DT As Long DateTime.DateFormat = "yyyy-MM-dd'T'HH:mm:ss" DT = DateTime.DateParse(Attributes.GetValue(i)) DateTime.DateFormat = "dd-MMM-yyyy HH:mm" lblSchedStart.Text = DateTime.Date(DT) .... Click to expand... Wait what, Attributes.GetValue? What's that returning I thought that was related to xml? Or is it just an example? Also, dateformat can include the time? (Docs didn't say) - that may change things.
S SteveBee Member Licensed User Longtime User Jun 29, 2011 #11 This was just copied/pasted from my code. Attributes.GetValue(i) is just a value - yes I was parsing xml If it makes it easier for you: Code: Copy DT = DateTime.DateParse(strDateTime) where strDateTime is a string representation of a DT Upvote 0
This was just copied/pasted from my code. Attributes.GetValue(i) is just a value - yes I was parsing xml If it makes it easier for you: Code: Copy DT = DateTime.DateParse(strDateTime) where strDateTime is a string representation of a DT
H hackhack Active Member Licensed User Longtime User Jun 29, 2011 #12 Hey, I'm just easily confused - thanks for your input Upvote 0
S SteveBee Member Licensed User Longtime User Jun 29, 2011 #13 hackhack said: Hey, I'm just easily confused Click to expand... join the club, bro'... Upvote 0