Office Automation Date, PB equivalent of it?

Just starting out? Need help? Post your questions and find answers here.
User avatar
Thunder93
Addict
Addict
Posts: 1788
Joined: Tue Mar 21, 2006 12:31 am
Location: Canada

Office Automation Date, PB equivalent of it?

Post by Thunder93 »

What's the PB equivalent code for the following? Thanks in advanced.

Code: Select all

Dim d As Double
d = CType(Marshal.PtrToStructure(iPtr, GetType(Double)), Double)
dr(dc.ColumnName) = Date.FromOADate(d).ToLocalTime
ʽʽ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
User avatar
Thunder93
Addict
Addict
Posts: 1788
Joined: Tue Mar 21, 2006 12:31 am
Location: Canada

Re: Office Automation Date, PB equivalent of it?

Post by Thunder93 »

I know you PeekD() the memory, but after that I'm not sure exactly what to-do next...

Example of PeekD() Output: 42622.25267361111
ʽʽ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
User avatar
Thunder93
Addict
Addict
Posts: 1788
Joined: Tue Mar 21, 2006 12:31 am
Location: Canada

Re: Office Automation Date, PB equivalent of it?

Post by Thunder93 »

Was hoping I could figure it out. Taking the double return and make it show the date.

https://msdn.microsoft.com/en-us/librar ... adate.aspx
ʽʽ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
User avatar
Thunder93
Addict
Addict
Posts: 1788
Joined: Tue Mar 21, 2006 12:31 am
Location: Canada

Re: Office Automation Date, PB equivalent of it?

Post by Thunder93 »

Just going to resort to the Microsoft VariantTimeToSystemTime API. I prototyped it under different name. PB kept complaining about VariantTimeToSystemTime having incorrect number of parameters, and that wasn't true. It uses two, and I've specified just two. :x :wink:
ʽʽ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
Dude
Addict
Addict
Posts: 1907
Joined: Mon Feb 16, 2015 2:49 pm

Re: Office Automation Date, PB equivalent of it?

Post by Dude »

Don't ya hate it when nobody replies and you end up talking to yourself? ;) :mrgreen:

I thought I better post something here so you don't look like a madman. :lol:
User avatar
Thunder93
Addict
Addict
Posts: 1788
Joined: Tue Mar 21, 2006 12:31 am
Location: Canada

Re: Office Automation Date, PB equivalent of it?

Post by Thunder93 »

LOL! I figured if people around who had the answer, they would respond.

However your thoughtful. I don't want to look like a madman. :lol:
ʽʽ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
User avatar
Josh
Addict
Addict
Posts: 1183
Joined: Sat Feb 13, 2010 3:45 pm

Re: Office Automation Date, PB equivalent of it?

Post by Josh »

.
sorry for my bad english
User avatar
Thunder93
Addict
Addict
Posts: 1788
Joined: Tue Mar 21, 2006 12:31 am
Location: Canada

Re: Office Automation Date, PB equivalent of it?

Post by Thunder93 »

:lol:
ʽʽ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
User avatar
Thunder93
Addict
Addict
Posts: 1788
Joined: Tue Mar 21, 2006 12:31 am
Location: Canada

Re: Office Automation Date, PB equivalent of it?

Post by Thunder93 »

Josh... I see your mark, and this reminds me of an old heritage TV commercial https://www.historicacanada.ca/content/ ... s/inukshuk

:mrgreen:
ʽʽ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
User avatar
djes
Addict
Addict
Posts: 1806
Joined: Sat Feb 19, 2005 2:46 pm
Location: Pas-de-Calais, France

Re: Office Automation Date, PB equivalent of it?

Post by djes »

:lol:
I wanna let my mark too! :mrgreen:

Anyway, for the question, I think that PB doesn't need all this type/ptr/deprecated functions conversion spaghetti stuff. And to answer in a better way, we'd need input, and output type.
User avatar
Thunder93
Addict
Addict
Posts: 1788
Joined: Tue Mar 21, 2006 12:31 am
Location: Canada

Re: Office Automation Date, PB equivalent of it?

Post by Thunder93 »

I wasn't asking for PB to natively support the conversion. That Office Automation date isn't deprecated, Microsoft uses it still in ESE (JetBlue) database engine.

And the VariantTimeToSystemTime WinAPI hasn't been deprecated.

At least you've made your mark. :shock: :mrgreen:
ʽʽ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
User avatar
djes
Addict
Addict
Posts: 1806
Joined: Sat Feb 19, 2005 2:46 pm
Location: Pas-de-Calais, France

Re: Office Automation Date, PB equivalent of it?

Post by djes »

I haven't said that it's deprecated ;) I've said that all this conversion stuff could surely be cleaner in PB, as it's not suffering from multiple language evolution.
Anyway, I found someone talking on the forum about vbcorlib, and this by googling, maybe it could help a bit : http://www.kellyethridge.com/vbcorlib/d ... tatic.html
User avatar
Thunder93
Addict
Addict
Posts: 1788
Joined: Tue Mar 21, 2006 12:31 am
Location: Canada

Re: Office Automation Date, PB equivalent of it?

Post by Thunder93 »

I'm slow, but I'm here with you now. :oops: I agree entirely! :mrgreen:

I was working on a cross-platform DateTime formula. My math sucks, however I think I was making break-through with it. Factoring leap years and all dat. I'll post when I have something more substantial.
ʽʽ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
User avatar
djes
Addict
Addict
Posts: 1806
Joined: Sat Feb 19, 2005 2:46 pm
Location: Pas-de-Calais, France

Re: Office Automation Date, PB equivalent of it?

Post by djes »

Cool :)

From FromOADate page
The d parameter is a double-precision floating-point number that represents a date as the number of days before or after the base date, midnight, 30 December 1899. The sign and integral part of d encode the date as a positive or negative day displacement from 30 December 1899, and the absolute value of the fractional part of d encodes the time of day as a fraction of a day displacement from midnight. d must be a value between negative 657435.0 through positive 2958465.99999999.
Note that because of the way dates are encoded, there are two ways of representing any time of day on 30 December 1899. For example, -0.5 and 0.5 both mean noon on 30 December 1899 because a day displacement of plus or minus zero days from the base date is still the base date, and a half day displacement from midnight is noon.
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 ! :evil:
User avatar
Thunder93
Addict
Addict
Posts: 1788
Joined: Tue Mar 21, 2006 12:31 am
Location: Canada

Re: Office Automation Date, PB equivalent of it?

Post by Thunder93 »

LOL!!! Thanks for the laugh! :lol:
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 ! :evil:
ʽʽ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
Post Reply