Thunder93 wrote:LOL!!! Thanks for the laugh!
djes wrote:I really think that using floating numbers for date/time is crazy. Never I would have created such a thing. Just imagine that this kind of function could be used for planes or banking data makes me mad !
Office Automation Date, PB equivalent of it?
Re: Office Automation Date, PB equivalent of it?
Re: Office Automation Date, PB equivalent of it?
I only got down to the day, then I'm stumped... I told you I suck at math, but here Is what I have thus far.
Code: Select all
Debug "Our Goal: 09/09/2016 06:03:51"+#CRLF$
OADoubleValue.s = "42622.25267361111"
OADaysFROM1900 = Int(Val(OADoubleValue))
OAMilSecsFROM1900 = Val(StringField(OADoubleValue, 2, "."))
Year.l = OADaysFROM1900 / 365 : Debug "Year: "+Str(Year+1900)
Month.l = Year / 12 : Debug "Month: "+Month
Day.l = (OAMilSecsFROM1900 / 86400000) / 30 : Debug "Day: "+Day
Thunder93 wrote:I was working on a cross-platform DateTime formula. My math sucks, ....
ʽʽSuccess is almost totally dependent upon drive and persistence. The extra energy required to make another effort or try another approach is the secret of winning.ʾʾ --Dennis Waitley
Re: Office Automation Date, PB equivalent of it?
I don't think it could be that easy, as years are not always 365 days long, and months not always 31 days long, and don't forget the particular years where time has to be corrected... It could be a correct formula as long as it converts intervals in days, but getting the correct date from 1900 I doubt !
Edit
I found a lot of links about this oddity.
The best and funniest ones :
https://blogs.msdn.microsoft.com/ericli ... o-vt_date/ and especially this one (linked) : https://www.joelonsoftware.com/2006/06/16/my-first-billg-review/
Some useful with links :
http://stackoverflow.com/questions/7348 ... javascript
http://stackoverflow.com/questions/1055 ... at-in-ruby
Edit
I found a lot of links about this oddity.
The best and funniest ones :
https://blogs.msdn.microsoft.com/ericli ... o-vt_date/ and especially this one (linked) : https://www.joelonsoftware.com/2006/06/16/my-first-billg-review/
Some useful with links :
http://stackoverflow.com/questions/7348 ... javascript
http://stackoverflow.com/questions/1055 ... at-in-ruby
Re: Office Automation Date, PB equivalent of it?
I don't think that the leap year is a problem in this case, to retrieve the years.
since 1 January 1900, 42705 days past, brings us now onto 2017.
since 1 January 1900, 42705 days past, brings us now onto 2017.
Code: Select all
OADaysFROM1900.d = 42705.0
Debug OADaysFROM1900 / 365
Debug (OADaysFROM1900 / 365) + 1900
ʽʽSuccess is almost totally dependent upon drive and persistence. The extra energy required to make another effort or try another approach is the secret of winning.ʾʾ --Dennis Waitley
Re: Office Automation Date, PB equivalent of it?
Yes, but if you have to determine what year (not especially 2017) it was around dec 31, you surely will have problems sometimes...
Re: Office Automation Date, PB equivalent of it?
Yes... wayyyy to much variables. It's a shame PureBasic Date library doesn't support Microsoft Date.
ʽʽSuccess is almost totally dependent upon drive and persistence. The extra energy required to make another effort or try another approach is the secret of winning.ʾʾ --Dennis Waitley
Re: Office Automation Date, PB equivalent of it?
Thunder93
not sure if this helps...
not sure if this helps...
Code: Select all
;==================================================================
;
; Author: wayne-c
; Date: Jan 29, 2007
; Explain: http://forums.purebasic.com/english/viewtopic.php?p=180010&sid=6515b4e0c9eb795c8d96c9f62903c187#p180010
;
; Typical Usage: convert VariantTimeToSystemTime to date
;==================================================================
Import "oleaut32.lib"
VariantTimeToSystemTime(d.d, lpSystemTime.l)
EndImport
vt.d= 39111.5032638889
st.SYSTEMTIME
If VariantTimeToSystemTime(vt, @st)
d.d= Date(st\wYear, st\wMonth, st\wDay, st\wHour, st\wMinute, st\wSecond)
Debug FormatDate("%dd.%mm.%yyyy %hh:%ii:%ss", d)
EndIf
- It was too lonely at the top.
System : PB 6.10 LTS (x64) and Win Pro 11 (x64)
Hardware: AMD Ryzen 9 5900X w/64 gigs Ram, AMD RX 6950 XT Graphics w/16gigs Mem
System : PB 6.10 LTS (x64) and Win Pro 11 (x64)
Hardware: AMD Ryzen 9 5900X w/64 gigs Ram, AMD RX 6950 XT Graphics w/16gigs Mem
Re: Office Automation Date, PB equivalent of it?
ʽʽSuccess is almost totally dependent upon drive and persistence. The extra energy required to make another effort or try another approach is the secret of winning.ʾʾ --Dennis Waitley