Re: Date confusion
- From: "Douglas J. Steele" <NOSPAM_djsteele@xxxxxxxxxxxxxxxxx>
- Date: Sat, 10 Sep 2005 07:03:30 -0400
Matt: Read my reply elsewhere in this string. Much of what you're suggesting
is incorrect.
--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)
"matt -`;'-" <mbox1@xxxxxxxxxx> wrote in message
news:1b2de$43228bbf$97d50759$18274@xxxxxxxxxxxxx
>
> "Ace9x" <Ace9x@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
> news:AB5E3A45-94AD-4D46-8E23-9CA35AC56FED@xxxxxxxxxxxxxxxx
>> I have created a function in the Main module in Access, which when called
>> with a Financial Year parameter creates 52 weekly entries in a table with
>> period no as 1 to 52, start and end date. This seems okay until I view
>> the
>> new entries in the table. Some of the dates are displayed in dd/mm/yyyy
>> format whilst others appear in mm/dd/yyyy format. There are no format or
>> input masks present on the table itself.
>> For the sql insert statement of the 2 dates I used :-
>>
>> "#" & format(dteStart,"dd/mm/yyyy") ",#" & format(dteEnd,"dd/mm/yyyy") &
>> "#"
>>
>> Obviously something is wrong either with the insert SQL or the display of
>> the dates in the table, can someone please advise appropriately.
>>
>> Cheers,
>> Steve
>
> The dates you are probably working with are a numeric value that the
> program displays in a date format like m/d/y. The actual date
> value is a 5 digit Long Integer.
Actually, the date value is an 8 byte floating point number, where the
integer portion of the value represents the date as the number of days
relative to 30 Dec, 1899, and the decimal portion represents time as a
fraction of a day.
> If you are working with a numeric date and you want the format DDMMYYYY,
> then you will need to store the dates you use as String
> representations of a date in the Table. (The data type in the table will
> be text instead of date.) Visually this will look the
> same to you, but to the program it will see a Text String and will keep it
> properly formatted to dd/mm/yyyy. If you need to perform
> math on the dates then you will need to convert them back to date values.
> See below for both methods.
Why? Store the date as a date, and use a format statement to display it how
you want. Remember: the date is stored as a number, not in a specific
format.
> '--Convert a numeric date value to a string date value
> Format(CStr(dteStart),"dd/mm/yyyy")
> '--Convert a string date value formatted as DD/MM/YYYY to a numeric date
> value
> DateValue(Mid(strDate,4,2) & "/" & Left(strDate,2) & "/" &
> Right(strDate,4))
These are both iffy, since you're relying on Access to coerce the value from
a string into a date before it applies the format. Unless you can be certain
of what the user's Short Date setting is, it may not coerce the way you want
it to.
.
- Follow-Ups:
- Re: Date confusion
- From: matt -`;'-
- Re: Date confusion
- References:
- Re: Date confusion
- From: matt -`;'-
- Re: Date confusion
- Prev by Date: Re: Date confusion
- Next by Date: RE: transpose
- Previous by thread: Re: Date confusion
- Next by thread: Re: Date confusion
- Index(es):
Relevant Pages
|
Loading