Jim Lawrence (AccessD)
accessd at shaw.ca
Fri May 21 21:23:19 CDT 2004
Hi Rocky: I am glad to hear you have unraveled a solution... It should work. Good luck Jim -----Original Message----- From: accessd-bounces at databaseadvisors.com [mailto:accessd-bounces at databaseadvisors.com]On Behalf Of Rocky Smolin - Beach Access Software Sent: Sunday, May 23, 2004 2:13 PM To: Access Developers discussion and problem solving Subject: Re: [AccessD] Date Format Again Jim: Here's how I solved it. I have two dates encoded in the key - one is the license expiration date, the other is the date of last access. Every time the user starts the app I update this last access date in the key. (This stops the user from just rolling their clock back a year when the expiration date rolls around. If the system date is less than the last access date I give them a message that says 'adjust your system date', and quit the app.) So, instead of trying to reconstruct the expiration and last access dates correctly based on the user's regional settings I set up global variable to hold the month date and year: Public gintExpirationDay As Integer Public gintExpirationMonth As Integer Public gintExpirationYear As Integer Public gintLastAccessDay As Integer Public gintLastAccessMonth As Integer Public gintLastAccessYear As Integer and put the values in there when I decrypt them from the key. Then, everywhere I need to do a test I use the DateSerial function with the proper values: Like on the caption of the label on the opening screen which displays the expiration: "License Expires: " & Format(DateSerial(gintExpirationYear, gintExpirationMonth, gintExpirationDay), "Short Date") or checking the expiration date ' Check to see if license has expired If Date > DateSerial(gintExpirationYear, gintExpirationMonth, gintExpirationDay) Then MsgBox "License has expired. Please call Beach Access Software (858) 259-4334.", vbExclamation Application.Quit End If Hopefully this will be a global solution to the problem. Thanks for all inputs, folks. But the subject's not closed if there's a better way... Rocky Smolin Beach Access Software http://www.e-z-mrp.com ----- Original Message ----- From: "Jim Lawrence (AccessD)" <accessd at shaw.ca> To: "Access Developers discussion and problem solving" <accessd at databaseadvisors.com> Sent: Friday, May 21, 2004 3:46 AM Subject: RE: [AccessD] Date Format Again > Hi Rocky: > > Why not just store your expiry date in 'yyyymmdd' format. It can then be > used as a date or string and will still validate and sort correctly. Then > just DateSerial and Format their date, as previously described to match your > expiry date.... > > Dim TheirDate as Date > Dim MyExpiryDate as String > > TheirDate = Date > MyExpiryDate = "20040630" '30 June 2004 > > if str(format(DateSerial(Year(TheirDate), Month(TheirDate), > Day(TheirDate)),"yyyymmdd")) >= MyExpiryDate then > MsgBox "Your viewing time has expired, please contact.... > end if > > HTH > Jim > > -----Original Message----- > From: accessd-bounces at databaseadvisors.com > [mailto:accessd-bounces at databaseadvisors.com]On Behalf Of Rocky Smolin - > Beach Access Software > Sent: Thursday, May 20, 2004 9:18 AM > To: Access Developers discussion and problem solving > Subject: Re: [AccessD] Date Format Again > > > Drew: > > The date is encoded in three characters in the key - one for month, one for > day, one for year. I encode it from mm/dd/yy because I'm an ethnocentric > American. But the system may be shipped anywhere in the world where they > may be using little known date formats like dd/mm/yy. > > So when I uncode the expiration date from the key I have to know whether to > create an mm/dd/yy date or a dd/mm/yy date. I think. (There's probably a > better way, but I don't know what it is.) > > In the Taiwan case, they were using the (popular if common) American date > but had chosen yyyy-mm-dd for the short date format. Which caused another > problem. > > So now I'm thinking that instead of assembling the expiration date I could > just keep the month, day, and year in separate strings and use date serial > to compare to the date serial of the system date? Is that where you're > trying to lead me? Like: > > DateSerial(varExpireYear, varExpireMonth, varExpireDay) < > DateSerial(DatePart("yyyy",Date), DatePart("m",Date), DatePart("d",Date) > > ? > > Regards, > > Rocky Smolin > Beach Access Software > http://www.e-z-mrp.com > > > ----- Original Message ----- > From: <DWUTKA at marlow.com> > To: <accessd at databaseadvisors.com> > Sent: Thursday, May 20, 2004 8:53 AM > Subject: RE: [AccessD] Date Format Again > > > > Again, why Rocky? A date is a date. If you are 'encoding' it, you know > the > > format you have encoded it as. So if you are encoding mm/dd/yy, and you > > want to compare it to the local date, then just use DateSerial. > > > > It doesn't matter what region you are in, you are setting the encoding to > > the format that you want, right? > > > > Drew > > > > > > > > -----Original Message----- > > From: accessd-bounces at databaseadvisors.com > > [mailto:accessd-bounces at databaseadvisors.com]On Behalf Of Rocky Smolin - > > Beach Access Software > > Sent: Thursday, May 20, 2004 10:23 AM > > To: Access Developers discussion and problem solving > > Subject: Re: [AccessD] Date Format Again > > > > > > Jim: > > > > One problem - I'm not using a regular date. I'm assembling the date which > > is encoded in a key. So to build the date, I need to know the format to > > construct it in - mm/dd/yy or dd/mm/yy. > > > > I then compare it to the system date to see if the license has expired. > > > > Rocky > > > > ----- Original Message ----- > > From: "Jim Lawrence (AccessD)" <accessd at shaw.ca> > > To: "Access Developers discussion and problem solving" > > <accessd at databaseadvisors.com> > > Sent: Wednesday, May 19, 2004 6:04 PM > > Subject: RE: [AccessD] Date Format Again > > > > > > > Hi Rocky: > > > > > > Why do you not use this piece of code to check the date. It does not > > matter > > > what is the format of the date, in which region because a Day is still a > > > day, a Month is still a month and so on... The following code will > > translate > > > any date. > > > > > > if format(DateSerial(Year(Date), Month(Date), Day(Date)),"yyyymmdd") > > > > MyCutoffDate then... > > > > > > Just pick your required result format. > > > > > > HTH > > > Jim > > > > > > -----Original Message----- > > > From: accessd-bounces at databaseadvisors.com > > > [mailto:accessd-bounces at databaseadvisors.com]On Behalf Of Rocky Smolin - > > > Beach Access Software > > > Sent: Wednesday, May 19, 2004 8:06 AM > > > To: AccessD at databaseadvisors.com > > > Subject: [AccessD] Date Format Again > > > > > > > > > Dear List: > > > > > > I thought I had the date format problem solved but in Taiwan they use > the > > US > > > format but they've got their machines set to yyyy-mm-dd. > > > > > > The problem is that I have a license expiration date encrypted in a key > > and > > > so the routine that decodes the key yields (among other things) the > > > expiration date which I compare to the system date. > > > > > > So I guess I'm going to have to use an API to get the regional setting > for > > > short date format? I've been mucking around in the Knowledgebase but > > can't > > > seem to find what I want. > > > > > > Does anyone know the format for retrieving this item? > > > > > > I guess I will have to use a Select Case on the short date format to do > > the > > > decryption to yield a short date in the local format. And just add > cases > > as > > > I find more short date formats. > > > > > > MTIA, > > > > > > Rocky Smolin > > > Beach Access Software > > > http://www.e-z-mrp.com > > > > > > -- > > > _______________________________________________ > > > AccessD mailing list > > > AccessD at databaseadvisors.com > > > http://databaseadvisors.com/mailman/listinfo/accessd > > > Website: http://www.databaseadvisors.com > > > > > > -- > > > _______________________________________________ > > > AccessD mailing list > > > AccessD at databaseadvisors.com > > > http://databaseadvisors.com/mailman/listinfo/accessd > > > Website: http://www.databaseadvisors.com > > > > > > > -- > > _______________________________________________ > > AccessD mailing list > > AccessD at databaseadvisors.com > > http://databaseadvisors.com/mailman/listinfo/accessd > > Website: http://www.databaseadvisors.com > > -- > > _______________________________________________ > > AccessD mailing list > > AccessD at databaseadvisors.com > > http://databaseadvisors.com/mailman/listinfo/accessd > > Website: http://www.databaseadvisors.com > > -- > _______________________________________________ > AccessD mailing list > AccessD at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/accessd > Website: http://www.databaseadvisors.com > > -- > _______________________________________________ > AccessD mailing list > AccessD at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/accessd > Website: http://www.databaseadvisors.com -- _______________________________________________ AccessD mailing list AccessD at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/accessd Website: http://www.databaseadvisors.com