[Newby] About Date

Just starting out? Need help? Post your questions and find answers here.
Dare2
Moderator
Moderator
Posts: 3321
Joined: Sat Dec 27, 2003 3:55 am
Location: Great Southern Land

Post by Dare2 »

Hi buzzqw,

As Behnood and Jan Vooijs have just explained to you and me, there is a base date of 1970.

So all calculations are based on seconds since the start of 1970. That means you need to get the year and subtract 1970.



@Jan,

Turbo pascal! Real programmers coded in BasicA! :P ;)
@}--`--,-- A rose by any other name ..
Jan Vooijs
Enthusiast
Enthusiast
Posts: 196
Joined: Tue Sep 30, 2003 4:32 pm
Location: The Netherlands

Post by Jan Vooijs »

Dare2,

Well BasicA did not have the date calculus!! So :P I used TP (from 1.0 till 7.0 allthough tje latter was BP not TP)

Subtracting 1970 from the date is a bit of a problem since it is a string!!! Better would be an other function. Or this way:

Code: Select all

date1=ParseDate("%yyyy/%mm/%dd", "2004/03/01")
date2=ParseDate("%yyyy/%mm/%dd", "2006/01/24")
date_bet=date2-date1

Debug date_bet


Text.s = FormatDate( "%yyyy/%mm/%dd", Date_bet)

Debug Text.s


Debug Year( Date_bet) - 1970
Debug Month( Date_Bet)
Debug Day( Date_bet) 

; or :

Debug "Years...: " + Str( Year( Date_bet) - 1970)
Debug "Months..: " + Str( Month( Date_Bet))
Debug "Days....: " + Str( Day( Date_bet))
Cheers,

Jan V.
Life goes to Fast, Enjoy!!

PB 4 is to good to be true, wake up man it is NOT a dream THIS is a reality!!!

AMD Athlon on 1.75G, 1Gb ram, 160Gb HD, NVidia FX5200, NEC ND-3500AG DVD+RW and CD+RW, in a Qbic EO3702A and Win XP Pro SP2 (registered)
Behnood
User
User
Posts: 72
Joined: Fri Apr 25, 2003 10:07 pm
Location: Australia
Contact:

Post by Behnood »

@buzzqw
why you tried to subtract 1/1/1970?! cause i think date() will return zero for that date (it's the base date) so how many seconds past after 1/1/1970 until 1/1/1970? sure zero (infact it's what i think must be)
buzzqw
Enthusiast
Enthusiast
Posts: 116
Joined: Sat Aug 27, 2005 10:13 pm
Location: Italy
Contact:

Post by buzzqw »

:thanks: !!! to ALL !!!

BHH
Post Reply