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.

Author
Message
Slartibardfast
16
Years of Service
User Offline
Joined: 3rd Jul 2010
Location: Magrathea
Posted: 4th Apr 2011 00:27
I am seeking some help as to how to apply logic to dates. As far as I can tell, the only command in DBP regarding Dates is GET DATE$() which returns a string in the format dd/mm/yy.

If I want to calculate the number of days between 2 different dates for example, there are no DBP functions to do this?

Can anyone help with a code snippet (or point to a resource that gives same) whereby I can convert the DBP String representation of a date into Julian Format and Vice versa, as I think this would do the trick.

Much obliged anyone.
Phaelax
DBPro Master
23
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 4th Apr 2011 09:26 Edited at: 4th Apr 2011 09:45
Wrote a set of functions for you.
The time returned in seconds, while representative of originating from Jan 1 1970, cannot be used in conjunction with existing date functions in other languages because these function do not account for leap seconds as others are based on the unix epoch.



The Internet: Where men are men, women are men, and children are federal agents
Slartibardfast
16
Years of Service
User Offline
Joined: 3rd Jul 2010
Location: Magrathea
Posted: 4th Apr 2011 17:28
Spot on! You wrote that just for me? Surely not... I am honoured Anyway, thank you very much! It also gives me a nice humeric handle on dates for File I/O purposes (Save/Read), which was also a need I have, particularly when using Binary Files.
Phaelax
DBPro Master
23
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 4th Apr 2011 22:12
Just for you!

The Internet: Where men are men, women are men, and children are federal agents
Rich Dersheimer
AGK Developer
17
Years of Service
User Offline
Joined: 1st Jul 2009
Location: Inside the box
Posted: 5th Apr 2011 20:56
Just out of curiosity... what does "humeric" mean?

Slartibardfast
16
Years of Service
User Offline
Joined: 3rd Jul 2010
Location: Magrathea
Posted: 5th Apr 2011 22:01
A number with a sense of humour?

It means I pressed the wrong key, as in a temporary rush of **** to the brain! Or to put it another way:

10111010010100100011011! or even:

IF HandEyeCoordination <> TRUE
INPUT "Press the wrong key", Doh$
ENDIF
Rich Dersheimer
AGK Developer
17
Years of Service
User Offline
Joined: 1st Jul 2009
Location: Inside the box
Posted: 5th Apr 2011 22:15
Ah, I see. I thought it had something to do with "humane" in your other thread. Doh!

Slartibardfast
16
Years of Service
User Offline
Joined: 3rd Jul 2010
Location: Magrathea
Posted: 6th Apr 2011 00:26
I think I like your allusion better...
GIDustin
18
Years of Service
User Offline
Joined: 30th May 2008
Location:
Posted: 30th Apr 2011 02:45
Phaelax:

I love storing time as a unix timestamp because it is really easy to compare times. However, your example code says that today is May 3, 2013.

Phaelax
DBPro Master
23
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 2nd May 2011 00:54
That's weird, I just ran the code and it told me today was Jan 5, 2011.

Slartibardfast
16
Years of Service
User Offline
Joined: 3rd Jul 2010
Location: Magrathea
Posted: 2nd May 2011 18:39
I remember getting an error with the date handling (though I can't remember the specifics now). I made some adjustments to:



Which seemed to sort it for me.

p.s. I am very grateful for such help as this. It is a big time hassle saver for us part timers...

Login to post a reply

Server time is: 2026-07-11 12:20:44
Your offset time is: 2026-07-11 12:20:44