Connecting Tech Pros Worldwide Forums | Help | Site Map

How to convert Date to String

galsaba
Guest
 
Posts: n/a
#1: Nov 13 '05
I created a form with the following fields:

ID (AutoNumber)
Date (Date / Time)
Name (Text)

I want to create a query that will take
the first letter of the Name & Date & ID & last digit of the ID.

Thanks,

galsaba


PC Datasheet
Guest
 
Posts: n/a
#2: Nov 13 '05

re: How to convert Date to String


Put the following expression in the first field of the query:
MyResult:Left([Name],1) & Left([Date],1) & Left([ID],1) & Right([ID],1)

Note that Date and Name are reserved word.s You need to change the names of
those fields.

--
PC Datasheet
Your Resource For Help With Access, Excel And Word Applications
resource@pcdatasheet.com
www.pcdatasheet.com




"galsaba" <galsaba@aol.com> wrote in message
news:1108061804.864711.227050@o13g2000cwo.googlegr oups.com...[color=blue]
> I created a form with the following fields:
>
> ID (AutoNumber)
> Date (Date / Time)
> Name (Text)
>
> I want to create a query that will take
> the first letter of the Name & Date & ID & last digit of the ID.
>
> Thanks,
>
> galsaba
>[/color]


Ken Snell
Guest
 
Posts: n/a
#3: Nov 13 '05

re: How to convert Date to String


SELECT (Left([Name], 1) & Format([Date], "yyyymmdd") & Right([ID], 1)
AS MyTextString
FROM MyTableName;

Also, do not use Name or Date as the name of a field. They and many other
words are reserved words in ACCESS, and can create serious confusion for
ACCESS and Jet. See these Knowledge Base articles for more information:

List of reserved words in Access 2002 and Access 2003
http://support.microsoft.com/default...b;en-us;286335

List of Microsoft Jet 4.0 reserved words
http://support.microsoft.com/?id=321266

Special characters that you must avoid when you work with Access
databases
http://support.microsoft.com/?id=826763

--

Ken Snell
<MS ACCESS MVP>

"galsaba" <galsaba@aol.com> wrote in message
news:1108061804.864711.227050@o13g2000cwo.googlegr oups.com...[color=blue]
>I created a form with the following fields:
>
> ID (AutoNumber)
> Date (Date / Time)
> Name (Text)
>
> I want to create a query that will take
> the first letter of the Name & Date & ID & last digit of the ID.
>
> Thanks,
>
> galsaba
>[/color]


galsaba
Guest
 
Posts: n/a
#4: Nov 13 '05

re: How to convert Date to String


it did not give me the reulst.
If the name is Galsaba
and the date is 2/10/05
and the id is 1234

the result should be
G0210054

Thanks

Galsaba

Ken Snell
Guest
 
Posts: n/a
#5: Nov 13 '05

re: How to convert Date to String


Then change the format argument used in Format to give you the desired
"date" format in the string (I used "yyyymmdd" as an example format):

SELECT (Left([Name], 1) & Format([Date], "mmddyy") & Right([ID], 1)
AS MyTextString
FROM MyTableName;

The above assumes that "02/10/05" means February 10, 2005.

--

Ken Snell
<MS ACCESS MVP>


"galsaba" <galsaba@aol.com> wrote in message
news:1108066108.446155.17070@l41g2000cwc.googlegro ups.com...[color=blue]
> it did not give me the reulst.
> If the name is Galsaba
> and the date is 2/10/05
> and the id is 1234
>
> the result should be
> G0210054
>
> Thanks
>
> Galsaba
>[/color]


Closed Thread


Similar Microsoft Access / VBA bytes