Connecting Tech Pros Worldwide Help | Site Map

How to convert Date to String

 
LinkBack Thread Tools Search this Thread
  #1  
Old November 13th, 2005, 07:17 AM
galsaba
Guest
 
Posts: n/a
Default How to convert Date to String

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, 07:17 AM
PC Datasheet
Guest
 
Posts: n/a
Default 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, 07:17 AM
Ken Snell
Guest
 
Posts: n/a
Default 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, 07:17 AM
galsaba
Guest
 
Posts: n/a
Default 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, 07:17 AM
Ken Snell
Guest
 
Posts: n/a
Default 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]


 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,989 network members.