Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / Time$ and Date$ function data extraction

Author
Message
Mariner
21
Years of Service
User Offline
Joined: 28th Feb 2003
Location: United States
Posted: 1st Mar 2003 02:31
My project requires computation of the Julian Day number in order to calculate the positions of the planets, Moon and Sun with great precision. To do this, the year, month, day, hour, minute and seconds of the date must be available as separate integers. Other basic languages have functions such as NOW() which returns the system date and time. The other data can be obtained with:
Year(NOW()), MONTH(NOW())....SECOND(NOW)). These useful functions are not available on DBP. TIMER does not return absolute time, only relative time in milliseconds.
Date and time are available as strings in DBP using GET DATE$ and GET Time$. I have tried parsing the DATE$() and TIME$() functions with LEFT$, MID$ and RIGHT$ functions and can get the year and month, and hour and second (end values. However, MID$ returns only a single digit for day and minute or a single digit and a virgule, depending on the value used. Also, the extracted data are strings and I am unable to recast them as integers.
I would love to see a patch adding the missing functions, but for now would just appreciate a workable method of extraction of the individual numbers as ntegers.

I would appreciate any suggestions. Thanks, Mariner
Easily Confused
22
Years of Service
User Offline
Joined: 22nd Oct 2002
Location: U.K. Earth. (turn right at Venus)
Posted: 1st Mar 2003 03:47
True, Mid$() is somewhat limited but I can provide you with a small function where you can set the length of return:



As for converting strings to integers you need to use the Val() command as the following example I hope will show:



I hope this is useful to you

Programming anything is an art, and you can't rush art.
Unless your name is Bob Ross, then you can do it in thirty minutes.
Easily Confused
22
Years of Service
User Offline
Joined: 22nd Oct 2002
Location: U.K. Earth. (turn right at Venus)
Posted: 1st Mar 2003 03:53
Whoops, I got the days and months the wrong way around:



Silly me

Programming anything is an art, and you can't rush art.
Unless your name is Bob Ross, then you can do it in thirty minutes.
MrTAToad
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: United Kingdom
Posted: 1st Mar 2003 03:57
I've got a plug-in that calculates Julian dates for a given dd/mm/yy date.

Good news everyone! I really am THAT good...
http://www.nickk.nildram.co.uk/ for great plug-ins - oh my, yes!
Mariner
21
Years of Service
User Offline
Joined: 28th Feb 2003
Location: United States
Posted: 1st Mar 2003 22:20
To Easily Confused: Thanks for the coding lesson. I guess I am just spoiled and lazy. I originally learned the old Dartmouth BASIC on a Data General NOVA and moved to an
HP-85, Rocky Mountain BASIC and then to VB. I am in my sixties, but am not to old to learn and appreciate good advice.
To MrTAToad: I looked at your plugins but did not find the one you mentioned. I have the VB code I wrote for the Julian Day Number and it plugs into DB just fine. Thanks for the offer though.

MrTAToad
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: United Kingdom
Posted: 2nd Mar 2003 01:02
Sigh...

Did you try http://www.nickk.nildram.co.uk/page22.html?

Good news everyone! I really am THAT good...
http://www.nickk.nildram.co.uk/ for great plug-ins - oh my, yes!
Mariner
21
Years of Service
User Offline
Joined: 28th Feb 2003
Location: United States
Posted: 3rd Mar 2003 06:46
To MrTAToad: I do appreciate the offer. However it appears that your code calculates a date in the Julian calendar from a date in the Gregorian calendar. The Julian Day Number (JDE) has nothing at all to do with the Julian calendar. It is just the number of days and fractions of days since the noon, Jan.1 of the year -4712 Gregorian. The number takes into account the Gregorian calendar reform of 1582. JDE is used in the calculation of the lunar and planetary orbits and the precession and nutation of the Earth. The calculation of JDE is much simpler that calculating dates from one calendar into the other. I use the method in Astronomical Algorithms, a great book by Jean Meeus, a well known Belgian astronomer.

Regards, Jim M.

MrTAToad
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: United Kingdom
Posted: 3rd Mar 2003 23:43
Fair enough.

Good news everyone! I really am THAT good...
http://www.nickk.nildram.co.uk/ for great plug-ins - oh my, yes!

Login to post a reply

Server time is: 2024-11-24 03:54:20
Your offset time is: 2024-11-24 03:54:20