>>>Is there a way of returning the current month as a number? >> >> I had thought I had come up with a function for this, but it is >> getting the >> ends of some months wrong, eg 1 May is coming out as 31 Apr! (Which >> seems >> odd as I thought I had checked out all the month bounds when >> writing the >> function...I'll have another look at it tomorrow.) > > Had a fiddle with it this evening, and seem to have solved the > problems > (I've checked it against the QL's DATE$() and it's matched as far as > today > from 1 Jan 1961): <snip> > I could have set a string and made it a function, but the whole > point of the > exercise was that you were trying to extract the day/month/year from > the > DATE$ (if I understood you properly) and it would have been a bit > silly to > package them up in a string to be unpackaged again afterwards. An > alternative would be to add the three elements together, eg: > > packed = (year - 1961) * 372 + (month - 1) * 31 + day - 1 > > Then: > > day = packed MOD 31 + 1 > month = INT(packed / 31) MOD 12 + 1 > year = 1961 + INT(packed / 372) > > my_mth_no takes one param: secs since ~ and returns the month number > of that > date: > > month = my_mth_no(secs) > > > Any help? Yes! Thank you. I can see this is very useful if th emethod I'm actually using fails to work for any reason.
It's a very different approach to that which I took, which is more like that suggested by Wolfgang - extracting the 'active' language data by using DATE$ with a parameter at various steps in the clock's first year to extract the month names, and date$ with day-length steps to extract the day names. I have a DATA list of the full month names for the calendar display in the languages currently supported by SMSQ/E, and if the LANGUAGE function returns a value unknown to QDiary, it simply defaults to using the 3 letter month names extracted as Wolfgang suggested. It seems to work even if the programming is a little clumsy and not as tidy as I'd like. There were articles in QL Today about calendars and time-related subjects (especially liked the Star Trek stardates!) which have also been very helpful. In fact, as I was given permission to include those articles on the Documentation CD, may I ask you if I can also include these routines as well? If so, a few lines explaining the algorithm may be in order. I understand parts of it, but not all of it: for example what's the significance of the (dy+0.8) ? -- Dilwyn Jones -- No virus found in this outgoing message. Checked by AVG Free Edition. Version: 7.1.405 / Virus Database: 268.12.4/448 - Release Date: 14/09/2006 _______________________________________________ QL-Users Mailing List http://www.q-v-d.demon.co.uk/smsqe.htm