Now function issues

G

Gary Hillerson

I have a function that calls Cstr(Now()), producing a string like
"4/7/2009 11:39:06 PM"

I use that string in a call that I make to a registration server and
all works fine, except for when my code is used on PCs in certain
countries like Saudi Arabia or Korea.

What happens then is that Cstr(Now()) produces a string the contains
some non-ascii characters between the "2009" and the "11" (in the
example above).

I'm assuming that some localization code on the computer is causing
this, though I don't know exactly what is happening. It looks to me
like I can fix this by deleting non-ascii chars after call CStr.

Does anyone know anything more about what might be happening here?

- Gary
 
T

Tony Jollans

The regional settings - default date format - can affect this. Depending on
exactly what you want, you may be able to achieve it with a Format function
and appropriate format string -- Format(Now(), "whatever")
 
G

Gary Hillerson

Thanks for pointing me at the Format function, Tony.

When i called CStr(Now()), the conversion used the system-dependent
version of the date format. I'm now using Format instead of CStr, and
overriding that default so international considerations are
simplified.

Couldn't have done it without you.

G
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top