QB64 Phoenix Edition
DATE$ function - Printable Version

+- QB64 Phoenix Edition (https://qb64phoenix.com/forum)
+-- Forum: QB64 Rising (https://qb64phoenix.com/forum/forumdisplay.php?fid=1)
+--- Forum: Code and Stuff (https://qb64phoenix.com/forum/forumdisplay.php?fid=3)
+---- Forum: Help Me! (https://qb64phoenix.com/forum/forumdisplay.php?fid=10)
+---- Thread: DATE$ function (/showthread.php?tid=2060)

Pages: 1 2 3 4 5 6


RE: DATE$ function - PhilOfPerth - 10-26-2023

(10-26-2023, 12:27 AM)Kernelpanic Wrote: Reminds me of local forums where people kept popping up and wanting advice on how to turn off or delete this and that in order to save storage space - for hard drives with a terabyte or more.

These people almost always showed up after days or a few weeks with a cry for help: "My system suddenly crashed. I do not know why. How can I save my data (No backup, of course. They are experts!)?".

The world is full of experts, and they are not getting any less.  Tongue

An oldy, but for what it's worth:  x denotes the unknown; Spurt is a drip under pressure.


RE: DATE$ function - eoredson - 10-27-2023

Maximum int64 seconds in years:

Code: (Select All)
Dim y As _Integer64
Dim s As _Integer64
Dim d As _Integer64

s = 86400 ' seconds
d = 365 ' days

Dim t As _Integer64
y = 292277026596 ' years
t = y * s * d
Print "Maxint="; t
Print "Overflow Maxint= "; t * 2



RE: DATE$ function - SMcNeill - 10-27-2023

(10-27-2023, 11:04 PM)eoredson Wrote: Maximum int64 seconds in years:

Code: (Select All)
Dim y As _Integer64
Dim s As _Integer64
Dim d As _Integer64

s = 86400 ' seconds
d = 365 ' days

Dim t As _Integer64
y = 292277026596 ' years
t = y * s * d
Print "Maxint="; t
Print "Overflow Maxint= "; t * 2

Your number is wrong.
292,277,026,596  <-- Your number of years.
292,471,208,677  <-- Max number of years, stored as seconds, without overflowing.

Code: (Select All)
Screen _NewImage(800, 600, 32)

Dim maxInt64 As _Integer64
maxInt64 = 9223372036854775807

Dim y As _Integer64
Dim s As _Integer64
Dim d As _Integer64

s = 86400 ' seconds
d = 365 ' days

Dim t As _Integer64
y = 292277026596 ' years
t = y * s * d
Print "Maxint="; t
Print "Overflow Maxint= "; t * 2

Print
Print "Correct Values"
Print Int(maxInt64 / (86400&& * 365&&)) '60 seconds in 60 minutes in 24 hours in 365 days
Print maxInt64; " <== Max INT64"
Print 292471208677&& * 86400&& * 365&&; " <== Max number of years in seconds, you can store in an INT64"

This is a simple case of division.  Why's it so hard to get the correct answer here?  Am I missing something?


RE: DATE$ function - eoredson - 10-27-2023

Quote:This is a simple case of division.  Why's it so hard to get the correct answer here?  Am I missing something?
Except for leap years I just know this is what I got from Wikipedia.

https://en.wikipedia.org/wiki/Time_formatting_and_storage_bugs#Year_292,277,026,596

Erik.


RE: DATE$ function - SMcNeill - 10-28-2023

(10-27-2023, 11:29 PM)eoredson Wrote:
Quote:This is a simple case of division.  Why's it so hard to get the correct answer here?  Am I missing something?
Except for leap years I just know this is what I got from Wikipedia.

https://en.wikipedia.org/wiki/Time_formatting_and_storage_bugs#Year_292,277,026,596

Erik.

So you know where that number came from -- it has nothing to do with whatever you were trying to accomplish and show with your example:

Code: (Select All)
Screen _NewImage(800, 600, 32)
Dim maxInt64 As _Integer64
maxInt64 = 9223372036854775807&&
Print maxInt64; " <== Max INT64"
Print Int(maxInt64 / (86400&& * 365.2425##)); " <== Max number of years." '60 seconds in 60 minutes in 24 hours in 365.2425 days
Print 292277024626 + 1970; " <== Unix time started in 1970, so add 1970"
Print 292277026596; " <== The time from Wiki."



RE: DATE$ function - eoredson - 10-28-2023

Ok, that works. Thanks.

Erik.