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

RickV

Member
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")
 

DonManfred

Expert
Licensed User
Longtime User
I am parsing a Windows Date value, a double precision number, to my B4A app and need to format it as follows
where does the value comes from? A Database?
 
Upvote 0

PaulMeuris

Active 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

Active 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
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
thank you. I will try the code in the morning. ☺
 
Upvote 0
Top