zee
New Member
Posts: 6
|
Post by zee on Sept 4, 2018 7:59:56 GMT
print date$() ' Nov 30, 1999 as string is for today's date.
How do you calculate tomorrow and future dates with the same format with the months in letters?
|
|
|
Post by Rod on Sept 4, 2018 11:07:22 GMT
You can do date arithmatic by finding the days value of the starting date then adding or subtracting days from that value . Use the resultant days to print the date you are interested in.
Worth spending time with all of the date function values shown in the help file. It will make more sense once you have had a play with the function.
|
|
zee
New Member
Posts: 6
|
Post by zee on Sept 4, 2018 11:49:21 GMT
I know what your talking about but you didn't answer my question.
print date$() returns Sep 4, 2018.
What do you do to get Sep 6, 2018.
I know you can do it to get 09/04/2018 but I want to use letters for the month.
|
|
|
Post by B+ on Sept 4, 2018 17:50:14 GMT
OK you have me playing around with date stuff. I came up with this: while 1 input "Enter date (m/d/yr) to format ";tDate$ if tDate$ = "" then end m = val(tDate$) month$ = word$("JAN FEB MAR APR MAY JUN JUL AUG SEP OCT NOV DEC", m) 'thanks Rod target = date$(tDate$) day$ = word$("TUE WED THU FRI SAT SUN MON",target mod 7+1) 'thanks Rod date$ = leftOf$(rightOf$(tDate$, "/"), "/") year$ = rightOf$(rightOf$(tDate$, "/"), "/") print day$;" ";month$;" ";date$;", ";year$ wend
'date math example from Help ' today = date$("days") ' target = date$("1/1/2004") 'subsititute value for next year ' print "Days until the new year: "; ' print target - today
FUNCTION leftOf$ (source$, of$) posOf = INSTR(source$, of$) IF posOf > 0 THEN leftOf$ = MID$(source$, 1, posOf - 1) END FUNCTION
FUNCTION rightOf$ (source$, of$) posOf = INSTR(source$, of$) IF posOf > 0 THEN rightOf$ = MID$(source$, posOf + LEN(of$)) END FUNCTION
Maybe it helps?
|
|
|
Post by Rod on Sept 5, 2018 17:42:00 GMT
print date$() nodays=date$("days")+7
print word$("Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec",val(date$(nodays)));" "; print mid$(date$(nodays),4,2);", "; print mid$(date$(nodays),7,4)
|
|
zee
New Member
Posts: 6
|
Post by zee on Sept 9, 2018 4:47:49 GMT
B+
date$ = leftOf$(rightOf$(tDate$, "/"), "/") is getting a compiling error:
Type mismatch. Array rightOf$() requires numeric parameters
|
|
|
Post by B+ on Sept 9, 2018 12:13:13 GMT
B+ date$ = leftOf$(rightOf$(tDate$, "/"), "/") is getting a compiling error: Type mismatch. Array rightOf$() requires numeric parameters Zee, you probably failed to add the one or both handy functions I posted with the main code: FUNCTION leftOf$ (source$, of$)
posOf = INSTR(source$, of$)
IF posOf > 0 THEN leftOf$ = MID$(source$, 1, posOf - 1)
END FUNCTION
FUNCTION rightOf$ (source$, of$)
posOf = INSTR(source$, of$)
IF posOf > 0 THEN rightOf$ = MID$(source$, posOf + LEN(of$))
END FUNCTION
That would explain why the compiler thinks rightOf$() is an array! ;D
|
|