Re: us date format
- From: "Douglas J. Steele" <NOSPAM_djsteele@xxxxxxxxxxxxxxxxx>
- Date: Sun, 22 Jan 2006 07:03:51 -0500
"Marshall Barton" <marshbarton@xxxxxxxxxx> wrote in message
news:00t5t1hu69a0bi5mdj75rttdc4ft1emddd@xxxxxxxxxx
> Douglas J. Steele wrote:
>
>>"Marshall Barton" wrote
>>> Bob Wickham wrote:
>>>
>>> I don't know the context where Steve recommended using CLng,
>>> but the only reason I can think of is to drop the Time part
>>> of a date value. Not to say Steve didn't have something
>>> clever in mind, but I do not see how it can help in a
>>> situation inolving the Default Value.
>>
>>I believe what Steve may have been suggesting is that you can use:
>>
>>Me![PaymentDate].DefaultValue = CLng(Me![PaymentDate])
>>
>>rather than
>>
>>Me![PaymentDate].DefaultValue = "#" & Format$(Me![PaymentDate],
>>"yyyy-mm-dd") & "#"
>
>
> I never thought of that. It is clever, but it does rely on
> Access to convert from a long to a date. While I don't
> really have a problem with that, it is not in the slightest
> portable to other contexts that don't provide the same
> implicit conversions.
I don't really understand this comment, Marsh.
I don't see any reliance on converting from a long to a date. Dates ARE
numbers, after all. You can use the numeric equivalent of the date anywhere.
Today (22 Jan, 2006) is 38739 days since 30 Dec, 1899, so CLng(Date) will
give you 38739:
?CLng(Date)
38739
You can add, say, 31 to that to get 38970 and then format that as a date,
and you'll get 22 Feb, 2006:
?38739 + 31
38770
?Format(38770, "dd mmm yyyy")
22 Feb 2006
I don't feel it even relies on knowing that dates start at 30 Dec, 1899: 0
could represent any date, and this approach would still work in Access.
> Based on that thinking, I wouldn't trust it in SQL Server
> SQL statements without seeing some definitive documentation
> to that effect.
I don't disagree with this statement: I believe SQL Server uses a different
start date (so that 0 isn't 30 Dec, 1899, like it is in Access and Excel),
but I'm not certain about that. However, even if your front-end is linked to
SQL Server, there's no reason why you can't use this "trick" to set the
default value for a field. If Access is doing translations when
communicating with SQL Server, it'll do the same translations in either
case.
--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no private e-mails, please)
.
- Follow-Ups:
- Re: us date format
- From: Marshall Barton
- Re: us date format
- References:
- us date format
- From: Bob Wickham
- Re: us date format
- From: Marshall Barton
- Re: us date format
- From: Bob Wickham
- Re: us date format
- From: RoyVidar
- Re: us date format
- From: Bob Wickham
- Re: us date format
- From: RoyVidar
- Re: us date format
- From: Bob Wickham
- Re: us date format
- From: Marshall Barton
- Re: us date format
- From: Douglas J. Steele
- Re: us date format
- From: Marshall Barton
- us date format
- Prev by Date: Using Format for textboxes
- Next by Date: Re: us date format
- Previous by thread: Re: us date format
- Next by thread: Re: us date format
- Index(es):
Relevant Pages
|