Author |
Topic: using the Date$ function (Read 554 times) |
|
Alincon
Full Member
member is offline
Posts: 147
|
|
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.
|
|
Logged
|
|
|
|
Alincon
Full Member
member is offline
Posts: 147
|
|
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.
|
|
Logged
|
|
|
|
Hans
New Member
member is offline
Gender:
Posts: 31
|
|
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
|
|
Logged
|
|
|
|
Mystic
Junior Member
member is offline
Gender:
Posts: 53
|
|
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 |
|
If you could, where would you put it?
|
|
Logged
|
- Rick
|
|
|
Jack Kelly
Full Member
member is offline
Gender:
Posts: 106
|
|
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
|
|
Logged
|
|
|
|
Hans
New Member
member is offline
Gender:
Posts: 31
|
|
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
|
|
Logged
|
|
|
|
Alincon
Full Member
member is offline
Posts: 147
|
|
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.
|
|
Logged
|
|
|
|
|