LB Booster
« using the Date$ function »

Welcome Guest. Please Login or Register.
Apr 1st, 2018, 03:55am



ATTENTION MEMBERS: Conforums will be closing it doors and discontinuing its service on April 15, 2018.
We apologize Conforums does not have any export functions to migrate data.
Ad-Free has been deactivated. Outstanding Ad-Free credits will be reimbursed to respective payment methods.

Thank you Conforums members.
Speed up Liberty BASIC programs by up to ten times!
Compile Liberty BASIC programs to compact, standalone executables!
Overcome many of Liberty BASIC's bugs and limitations!
LB Booster Resources
LB Booster documentation
LB Booster Home Page
LB Booster technical Wiki
Just BASIC forum
BBC BASIC Home Page
Liberty BASIC forum (the original)

« Previous Topic | Next Topic »
Pages: 1  Notify Send Topic Print
 thread  Author  Topic: using the Date$ function  (Read 553 times)
Alincon
Full Member
ImageImageImage


member is offline

Avatar




PM


Posts: 147
xx using the Date$ function
« Thread started on: Mar 15th, 2015, 9:49pm »

I'd like to see some code samples using the Date Function in LBB like these from the LB4 help file:

'This form of date$() produces this format
print date$() ' Nov 30, 1999 returns string
print date$("mm/dd/yyyy") ' 11/30/1999 returns string
print date$("mm/dd/yy") ' 11/30/99 returns string
print date$("yyyy/mm/dd") ' 1999/11/30 returns string - can be used for sorting
print date$("days") ' 36127 returns number - days since Jan 1, 1901
print date$("4/1/2002") ' 36980 returns number - days since Jan 1, 1901 for given date
print date$(36980) ' 04/01/2002 returns string - mm/dd/yyyy string returned
'when given days since Jan 1, 1901

r.m.

User IP Logged

Jack Kelly
Full Member
ImageImageImage


member is offline

Avatar




Homepage PM

Gender: Male
Posts: 106
xx Re: using the Date$ function
« Reply #1 on: Mar 16th, 2015, 11:39am »

Does the article "Date Formatting Extended Functionality" in the LB Booster technical Wiki help you?

http://bb4w.wikispaces.com/Date+Formatting+Extended+Functionality

User IP Logged

Alincon
Full Member
ImageImageImage


member is offline

Avatar




PM


Posts: 147
xx Re: using the Date$ function
« Reply #2 on: Mar 18th, 2015, 01:22am »

Yes, that's good info, but..

date$(mmmm dddd yyyy" works, but not "dddd" by itself
Maybe it's not supposed to.

There's nothing about Julian Dates. I use julian dates a lot to save space and for comparisons

I'll keep trying.

r.m.
User IP Logged

Hans
New Member
Image


member is offline

Avatar




PM

Gender: Male
Posts: 31
xx Re: using the Date$ function
« Reply #3 on: Mar 18th, 2015, 11:10am »

You can use the mid$() function on the received date string. You can't have it all grin
User IP Logged

Mystic
Junior Member
ImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 53
xx Re: using the Date$ function
« Reply #4 on: Mar 18th, 2015, 5:30pm »

on Mar 18th, 2015, 11:10am, Hans wrote:
You can't have it all grin


If you could, where would you put it? smiley
User IP Logged

- Rick
Jack Kelly
Full Member
ImageImageImage


member is offline

Avatar




Homepage PM

Gender: Male
Posts: 106
xx Re: using the Date$ function
« Reply #5 on: Mar 18th, 2015, 9:00pm »

r.m. -- Here's a function def for JulianDate$ that you can take a look at. Feel free to modify it to suit your needs. As written, it will only work in LBB because of the MID$ assignment feature.

Code:
print JulianDate$("today") ' not case sensitive
print JulianDate$("")
print JulianDate$("08/25/14") 
print JulianDate$("1/1/14") ' single digit month and day is ok
print JulianDate$("12 31 14") ' any separator is ok
print JulianDate$("12/31/12")
print JulianDate$("12/31/2000")
print JulianDate$("12/31/1900")
print JulianDate$("08-25-75") ' two digit year is the current (21st) century
print JulianDate$("08/25/1975") ' four digit year can be any century
print JulianDate$("august 25, 1975")
print JulianDate$("08/35/14") ' day error
print JulianDate$("13/25/14") ' month error

function JulianDate$(DateString$)
    JulianDate$="0000-000"
    if lower$(DateString$)="today" or DateString$="" then
            ObjectDays=date$("days")
            ObjectDate$=date$()
        else
            ObjectDays=date$(DateString$)
            if ObjectDays=0 then exit function
            ObjectDate$=DateString$
    end if
    ObjectYear$=right$(ObjectDate$,4)
    if val(left$(ObjectYear$,2))<9 then
        ObjectYear$=right$(ObjectYear$,2)
        ObjectCentury$="20"
        ObjectYear$=ObjectCentury$+ObjectYear$
    end if
    ObjectYear=val(ObjectYear$)
    EndPriorYear$="12/31/"+str$(ObjectYear-1)
    StartYearDays=date$(EndPriorYear$)
    ObjectOrdinal$=using("###", ObjectDays-StartYearDays)
    if val(ObjectOrdinal$)>366 then exit function
    for x=1 to len(ObjectOrdinal$)-1
        if mid$(ObjectOrdinal$,x,1)=" " then mid$(ObjectOrdinal$,x,1)="0"
    next x
    JulianDate$=ObjectYear$+"-"+ObjectOrdinal$
end function
 


User IP Logged

Hans
New Member
Image


member is offline

Avatar




PM

Gender: Male
Posts: 31
xx Re: using the Date$ function
« Reply #6 on: Mar 19th, 2015, 08:19am »

To stay with the original question, I was thinking of:
Code:
d$=date$("mmmm dddd yyyy")
print word$(d$,2) 

a bit differen from what i first suggested.

Hans
User IP Logged

Alincon
Full Member
ImageImageImage


member is offline

Avatar




PM


Posts: 147
xx Re: using the Date$ function
« Reply #7 on: Mar 20th, 2015, 02:42am »

Thanks again, Jack, but my question was about examples of using the Date function to get julian dates.
I found that LBB accepts the LB4 julian date format of the Date command, but it would be handy for that to be in the documentation.

Code:
print date$("4/1/2002") ' 36980 returns number - days since Jan 1, 1901 for given date 


r.m.
User IP Logged

Pages: 1  Notify Send Topic Print
« Previous Topic | Next Topic »

| |

This forum powered for FREE by Conforums ©
Terms of Service | Privacy Policy | Conforums Support | Parental Controls