UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
 
   Reply to this topicStart new topic
> UA Wiki Article: Date/time Functions., Any Version    
 
   
MaxWanadoo
post Sep 22 2013, 04:48 AM
Post#1



Posts: 151
Joined: 2-October 09



Hi Guys, I was just browsing the stuff in the Wiki Articles and in the Date/Time Functions for DTS there is this entry:
Public Const conSecond = 1.15740740740741E-05 ' There are 216,000 seconds in one day
Public Const conMinute = 6.94444444444445E-04 ' There are 3600 minutes in one day
Public Const conHour = 4.16666666666667E-02 ' There are 24 hours in one day
Could somebody tell me..
1. What are these constants meant to be and how are they used?
2. Why is it saying there are 216,000 seconds in one day when they are only 86.400 seconds in a day.
Also, as an aside, when viewing code is there any way to copy all the code. Ctrl+A gives the whole web page.
What would be nice (if available) to to be able to hightlight just the code without having to scroll through it with the shift key.
Thanks Guys
Max
Go to the top of the page
 
Bob G
post Sep 22 2013, 07:11 AM
Post#2


UtterAccess VIP
Posts: 11,184
Joined: 24-May 10
From: CT


it appears they got that from the incorrect minutes shown times 60
Go to the top of the page
 
jleach
post Sep 22 2013, 07:18 AM
Post#3


UtterAccess Editor
Posts: 9,804
Joined: 7-December 09
From: Staten Island, NY, USA


I'm not sure what's up with the constants: I'll check with Mark (CyberCow) as he's the one who posted the function(s).
Is for the copy code thing instead of the whole page, we can look into that. It'll require some javascript programming but would be a nice addition for both the forums as well as the wiki. I'll bring it up in the back rooms and we'll see what we can do with it.
Cheers,
Go to the top of the page
 
BananaRepublic
post Sep 22 2013, 07:40 AM
Post#4


Dungeon Cleaner
Posts: 1,504
Joined: 16-June 07
From: Banana Republic


For everyone, the article referred is Date/Time Functions.
That said, it does not be used in any functions showed there.
The date itself is stored as a double, with integer part representing number of days elapsed since December 30, 1899 while the fractional part represents time portion.
So for example, on September 9th, 2013 at 5:33:57 AM, the numeric equivalent is 41539.2319097222. That's 41539 days since December 30, 1899 while .2319097222 indicates that the day has elapsed 5 hours, 33 minutes and 57 seconds.
That said, I generally dislike manipulating the date as a number because once you do that, there is no guarantee that the calculations will be correct because there are a number of assumptions about how the calculations should be resolved and you'd have to know them all (no, we don't -- some may think we have it all but I doubt it and even if we did, why reinvent the wheel?).
The functions on the article actually correctly use various date functions such as DateAdd which handles all possible outliers that can happen during calculations and does not bother to use those 3 constants.
So, I guess what I'm saying is that if you have a specific uses that is not served by those existing date/time functions, you might be able to use constants but the date/time functions should be the first thing to prefer, IMHO.
HTH.
RE: Copy -- excellent idea. I too would find it useful.
Also if you don't mind me asking -- why did you start this topic and not use the wiki talk that was created?
Go to the top of the page
 
MaxWanadoo
post Sep 22 2013, 10:45 AM
Post#5



Posts: 151
Joined: 2-October 09



Actually, I did try to do that but it said I didn't have permission (or something to that effect). (I clicked on Reply)
Thanks
Max
Go to the top of the page
 
proegler
post Sep 22 2013, 11:20 AM
Post#6



Posts: 42
Joined: 1-September 13
From: Brooklyn,MI


The value of the constants (computed correctly as opposed to the comments) represent: Days per second, Days per minute and Days per hour. Obviously intended (but not used) for converting time to a fractional day.
Go to the top of the page
 
argeedblu
post Sep 22 2013, 11:32 AM
Post#7


UA Forum + Wiki Administrator
Posts: 14,057
Joined: 26-September 02
From: Sudbury, Ontario, Canada


As Banana pointed out the constants aren't used in the functions.
lt;<< What would be nice (if available) to to be able to hightlight just the code without having to scroll through it with the shift key. >>>
You still need to scroll but the Windows Click-Scroll-Shift-Click will work:
Click the beginning of the code. Scroll to the end of the code. Shift-click.
Glenn
Go to the top of the page
 
CyberCow
post Sep 22 2013, 11:43 AM
Post#8


UdderAccess Admin + UA Ruler
Posts: 19,555
Joined: 27-April 02
From: Upper MI


Yeah, it was typo - dunno how it happened cuz when I checked the code on my PC (and also in the Code Archive Date/Time Functions demo) it is set at 86,400.
nyway, it's now corrected.
Those cons are the values that can applied the numeric representation of date/time.
So, if there is a formula that results in in .345 days, it can be converted to seconds by dividing the ".345" by the conSecond constant (1.15740740740741E-05) to return the number of seconds. Or divide that same .345 days by the conMinute constant (6.94444444444445E-04) to return the number of minutes; and so on.
The constants and code are just helpers to work with real Date/Time values when just the numeric values are being worked with and are an attempt to help developers who work with date/time value differences that cross the midnight threshhold. But I agree with BananaRepublic in that real Date/Time values be used instead of numeric values only. The Wiki entry (as well as the same article in the Code Archive) is meant to help a developer by providing as many options as possible.
Since posting the Date/Time Functions, I've derived and posted the Custom DateDiff() Function to work only with Date/Time values in a non-numeric fashion to get a variety of output formats when working with date/Times.
HAs for copying the code, I cannot think of any slicker method of getting just the code than to hold the shift key while scrolling. Guess I could zip it up and set it as an attachment. (done)
Hope this helps and clarifies the situation - and thanks for the "head's up" on the typo. hat_tip.gif
Go to the top of the page
 
argeedblu
post Sep 22 2013, 11:47 AM
Post#9


UA Forum + Wiki Administrator
Posts: 14,057
Joined: 26-September 02
From: Sudbury, Ontario, Canada


Mark the comment for minutes is wrong also 60*24 = 1440
Glenn
Go to the top of the page
 
CyberCow
post Sep 22 2013, 11:51 AM
Post#10


UdderAccess Admin + UA Ruler
Posts: 19,555
Joined: 27-April 02
From: Upper MI


fixed!
Thanks Glenn! hat_tip.gif
Go to the top of the page
 
MaxWanadoo
post Sep 22 2013, 02:25 PM
Post#11



Posts: 151
Joined: 2-October 09



Hi Moo,
Thanks
Max
Go to the top of the page
 
MaxWanadoo
post Sep 22 2013, 02:49 PM
Post#12



Posts: 151
Joined: 2-October 09



Hey Moo,
Thanks for the Custom Date Function. That is really nice and save me a lot of head-scratching in the future.
Max
Go to the top of the page
 
CyberCow
post Sep 22 2013, 03:13 PM
Post#13


UdderAccess Admin + UA Ruler
Posts: 19,555
Joined: 27-April 02
From: Upper MI


Go to the top of the page
 


Custom Search
RSSSearch   Top   Lo-Fi    13th December 2017 - 12:28 AM