[AccessD] Date Format Again

DWUTKA at marlow.com DWUTKA at marlow.com
Wed May 19 10:20:14 CDT 2004


Rocky, I've seen this kind of discussion a lot on the list.  About comparing
dates with different regional settings.  I've also brought up this solution
a few times, but I think people tend to overlook it.

Date formats are just the 'human' method of identifying dates.  To Access, a
date is a Double Number.  The whole part is the date, and the decimal part
is the time.  So if you are trying to compare two dates, it really doesn't
matter what the regional settings are, it's a numerical value compare.

Now, from your post I might assume that you are encrypting a string
representation of your 'date'.  If that is the case, the easiest method to
force a string back to a date, AND be able to ignore the regional settings
is the DateSerial function.  (There is also a TimeSerial function).  The
DateSerial asks for a year, month, and day argument.  The order of the
arguments are not affected by regional settings, it's set in VB.  So, just
return a date variable using DateSerial feeding it the values from your
'date string', and you now have an actual 'date' to compare with Date().  No
muss, no fuss, and no API's.  (Not saying anything against API's, in fact I
use API's all the time, just don't see the big deal about dates, because
DateSerial is one very handy date function.)

Of course, dates and the functions involved can be a little confusing, in
fact, Date(), Time() and Now() are the only functions I know of off hand,
that not only return a value, but can also be put on the other side of =, to
SET their value.  Go figure.  It's no wonder that Dates and Times are a
complex subject.

Drew

-----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 10: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



More information about the AccessD mailing list