BBC BASIC for Windows
Programming >> BBC BASIC language >> isolating part of time$
http://bb4w.conforums.com/index.cgi?board=language&action=display&num=1387531553

isolating part of time$
Post by Danny on Nov 12th, 2012, 3:32pm

Hello

I would like to be able to take a part of the time$ information such as the day e.g. "Monday" and to put that into another variable.

Could someone let me know how to do this please.

Danny
Re: isolating part of time$
Post by admin on Nov 12th, 2012, 10:00pm

on Nov 12th, 2012, 3:32pm, Danny wrote:
I would like to be able to take a part of the time$ information such as the day e.g. "Monday" and to put that into another variable.

If you are looking to get only the abbreviated day name (Mon, Tue, Wed etc.) then that's trivial, you just take the first three characters of TIME$ (or four if you want the dot as well):

Code:
      weekday$ = LEFT$(TIME$,3)
      PRINT weekday$ 

But if you want the full name of the day, e.g. "Monday", the easiest way is probably to use the DATELIB library as follows:

Code:
      INSTALL @lib$+"DATELIB"
      
      mjd% = FN_today
      weekday$ = FN_date$(mjd%, "dddd")
      PRINT weekday$ 

Richard.
Re: isolating part of time$
Post by Danny on Nov 13th, 2012, 11:49am

Thank you Richard. That is exactly what I required.