Android Question How do I convert a Windows Date double to Wed 22 Mar 2023 22:06:27

RickV

Member
Licensed User
I am parsing a Windows Date value, a double precision number, to my B4A app and need to format it as follows

45007.9211458333 = Wed 22 Mar 2023 22:06:27

I have exhausted string utils and datefunctions libraries.

Does anyone have a solution ?

vb6 code was format((45007.9211458333 , "ddd dd mmm yyyy hh:mm:ss")
 

PaulMeuris

Well-Known Member
Licensed User
In the previous century some programs started counting dates from 1900/01/01.
B4X:
    Private startticks As Long = DateUtils.SetDate(1900,1,1)
    Dim per As Period = DateUtils.PeriodBetweenInDays(startticks,DateTime.Now)
    Log(per.Days)    ' between the dates not including
 
Upvote 0

PaulMeuris

Well-Known Member
Licensed User
B4X:
get_date_from_long(45000)

Private Sub get_date_from_long(numdays As Long)
    Private dayticks As Long = DateTime.TicksPerDay
    Private startticks As Long = DateUtils.SetDate(1900,1,1)
    Dim calcticks As Long = startticks + (dayticks * numdays)
    Log(DateTime.Date(calcticks))
End Sub
 
Upvote 0

RickV

Member
Licensed User
thank you. I will try the code in the morning. ☺
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…