Connecting Tech Pros Worldwide Help | Site Map

How to convert Date to String

  #1  
Old November 13th, 2005, 08:17 AM
galsaba
Guest
 
Posts: n/a
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

  #2  
Old November 13th, 2005, 08:17 AM
PC Datasheet
Guest
 
Posts: n/a

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]


  #3  
Old November 13th, 2005, 08:17 AM
Ken Snell
Guest
 
Posts: n/a

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]


  #4  
Old November 13th, 2005, 08:17 AM
galsaba
Guest
 
Posts: n/a

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

  #5  
Old November 13th, 2005, 08:17 AM
Ken Snell
Guest
 
Posts: n/a

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 Threads
Thread Thread Starter Forum Replies Last Post
how convert date to string sourabhmca answers 2 April 12th, 2007 10:36 PM
convert DATE to STRING format catgovind answers 7 February 7th, 2007 05:35 PM
How to convert date to string value? JenHu answers 15 November 21st, 2005 07:59 AM
convert date to string ? harshad taylor answers 2 November 20th, 2005 07:09 PM