More about Dates!

K

Kagsy

Dear Friends

I am from Scotland and my control panel is set to UK with
date format of dd/mm/yyyy, but why, when I run the
following dateadd function does it add 1 month to the US
date and not as I would like 1 day to the UK date. What is
the fix to this problem?

Dim StartDate As Date
StartDate = #1/4/04#

?dateadd("d",1,StartDate)
05/01/2004

Thanks pals

Kagsy
 
V

vdavid

In VBA, date const are always in US format. It is only in formula inside
access objets (query, controls) than local settings are used.
(where formula are converted to local name - in french for me - ex : in a
controlSource witha formula...)

VD (France)
 
J

JohnFol

Your problem is not the dateadd. For example, just do the following:

Dim StartDate As Date
StartDate = #1/4/04#
Debug.print StartDate

and you still get
04/01/2004

What you need to do (and generally this is a good idea all round) is be
explicit about which is the date and which is the month, ie

StartDate = #1/Apr/2004#


What I really object to with the way it's been done is the control is taken
away from the developer. For example

one of these MUST return false (irrespective of your regional settings)

? isdate("01/13/04")
True
? isdate("13/01/04")
True


anyway, whinge over. .. . .
 

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