Re: ADP ignoring my format code
From: Brendan Reynolds (brenreyn)
Date: 09/27/04
- Next message: Monte: "Re: Slow search when Search af Formatted"
- Previous message: John Qllg=E5rd?= Jensen : "Re: Form data lost when edited and saved"
- In reply to: Vadim Rapp: "Re: ADP ignoring my format code"
- Messages sorted by: [ date ] [ thread ]
Date: Mon, 27 Sep 2004 11:56:46 +0100
Hi Vadim,
Sorry about the delay in replying, I was ill for a few days last week.
If the month is all that is required, and MyDate is a Date variable, and
we're talking VBA, not SQL, then all we need is Month(MyDate).
As I remember it though, what the original poster wanted was a string
representation of a complete date in US format. That would work with Jet
SQL, which, in 32-bit versions, expects dates in that format, regardless of
the current locale.
The question I was attempting to address was the question posed in the
subject line, why was the formatting code not producing the expected result?
But there is I think another question here, which is whether this Jet SQL
technique is appropriate in an ADP/SQL Server context?
I'm not any kind of expert on SQL Server, but I see that the SQL Server
Books Online topic, "Writing International Transact-SQL Statements" lists
three solutions to this problem - use the ODBC timestamp, date, and time
escape clauses, use the unseperated numeric strings (yyyymmdd, which if I
remember correctly is what Lyle suggested) or use the CONVERT statement with
an explicit style parameter.
-- Brendan Reynolds (MVP) http://brenreyn.blogspot.com The spammers and script-kiddies have succeeded in making it impossible for me to use a real e-mail address in public newsgroups. E-mail replies to this post will be deleted without being read. Any e-mail claiming to be from brenreyn at indigo dot ie that is not digitally signed by me with a GlobalSign digital certificate is a forgery and should be deleted without being read. Follow-up questions should in general be posted to the newsgroup, but if you have a good reason to send me e-mail, you'll find a useable e-mail address at the URL above. "Vadim Rapp" <vrapp@nospam.polyscience.com> wrote in message news:%23aZNhJAoEHA.1052@TK2MSFTNGP10.phx.gbl... > Hello Brendan: > You wrote on Tue, 21 Sep 2004 11:42:27 +0100: > > BR> Better still, use the Format$ version of the function, which returns a > BR> String, rather than a Variant of sub-type String, avoiding the > BR> unnecessary implicit conversion from Variant to String). > > I think the proper way to address this problem is using functions like > DatePart. > > I.e. for example, if I want to extract the month from the date, the bad > code > will be > > Month = mid(MyDate,1,2) > > The good code will be > > Month = datepart("m",MyDate) > > This is good practice even for domestic-only applciations; for the > international ones, it's absolutely mandatory. > > Actually, the whole Y2K issue was because people were using (1) instead of > (2). > > > Vadim > ---------------------------------------- > Vadim Rapp Consulting > SQL, Access, VB Solutions > 847-685-9073 > www.vadimrapp.com >
- Next message: Monte: "Re: Slow search when Search af Formatted"
- Previous message: John Qllg=E5rd?= Jensen : "Re: Form data lost when edited and saved"
- In reply to: Vadim Rapp: "Re: ADP ignoring my format code"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|