[AccessD] Date Conversion Problem

Gustav Brock Gustav at cactus.dk
Wed Jun 4 02:41:31 CDT 2008


Hi Drew

Yes, but as I wrote, I don't know of any place or situation where it could be or should be in use. Perhaps at Gonzo but would he buy Rocky's app?
Also:

http://en.wikipedia.org/wiki/Calendar_date 

/gustav


>>> DWUTKA at marlow.com 04-06-2008 09:23 >>>
True, I do love DateSerial, I guess because it's so precise.  Would that
format you suggested fail with a custom regional format? (like
YYYY-DD-MM) Doesn't Windows allow custom formats?

Drew

-----Original Message-----
From: accessd-bounces at databaseadvisors.com 
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Gustav Brock
Sent: Wednesday, June 04, 2008 1:48 AM
To: accessd at databaseadvisors.com 
Subject: Re: [AccessD] Date Conversion Problem

Hi Rocky

> So I assemble the date in a string = "07/01/08".  
> Then I set that equal to a variable of Date type ..

This is where you goof. To carry out the implicit conversion of this,
Access first looks up the format of the regional settings to find out if
this string could represent a date. As this matches, a conversion is
done.
Drew loves DateSerial and it really is nice because the output is very
predictable and it allows you to create date values from components.
However, here it is not needed - just build your date string following
the ISO 8601 format. It will never fail (well, maybe, if the regional
format is yyyy-dd-mm but this is nowhere in use):

  gstrExpirationDate = "2008-07-01"
  gdatExpirationDate = gstrExpirationDate

or rather:

  gdatExpirationDate = CDate(gstrExpirationDate)

You can just as well get used to this format ... all docs on the new
datetime data types of SQL Server 2008 uses the ISO format.

/gustav


>>> rockysmolin at bchacc.com 04-06-2008 02:10 >>>
Dear List:
 
I have a license expiration date encrypted in a key. I decode the expiration
date when the user starts the app and store it in a string which I then set
to a date type variable for display.
 
Works fine here.  The expiration date is 7/1/2008.  So I assemble the date
in a string = "07/01/08".  Then I set that equal to a variable of Date type
-gdatExpirationDate =  gstrExpirationDate - and gdatExpirationDate has
7-1-2008 in it.
 
When I set regional and Language to Chinese (PRC) of Chinese (Taiwan)
however, gdatExpirationDate has 2007-1-8.  
 
I can't figure out how to make the date display correctly from the string I
assemble from the key regardless of the Regional and Language Settings.
 
Is there a way to do this so I don't have to know what the setting is?
 
MTIA
 
Rocky






More information about the AccessD mailing list