A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

how can I store short dates numbers only no slashes



 
 
Thread Tools Display Modes
  #1  
Old April 27th, 2006, 08:11 PM posted to microsoft.public.access.forms
external usenet poster
 
Posts: n/a
Default how can I store short dates numbers only no slashes

I am triing to concatenate parts of cells to create ID numbers but the Date
of Birth stores slashes and puts them into my ID numbers
  #2  
Old April 27th, 2006, 08:55 PM posted to microsoft.public.access.forms
external usenet poster
 
Posts: n/a
Default how can I store short dates numbers only no slashes

See VBA Help on the Month, Day, and Year functions. They return variants
(integers) representing the component part of the date. If YourDate =
12/13/2005

Month(YourDate) returns 12.

Sprinks

"eleeiv" wrote:

I am triing to concatenate parts of cells to create ID numbers but the Date
of Birth stores slashes and puts them into my ID numbers

  #3  
Old April 27th, 2006, 09:16 PM posted to microsoft.public.access.forms
external usenet poster
 
Posts: n/a
Default how can I store short dates numbers only no slashes

eleeiv wrote:
I am triing to concatenate parts of cells to create ID numbers but the Date
of Birth stores slashes and puts them into my ID numbers


The slashes aren't being stored, they are part of the display (based on
regional settings)

If you're trying to extract individual parts of the date to use in a
string ID or long ID, you're going to need to use the DatePart function

Example:
Dim intMonth as Integer
Dim intDay as Integer
Dim intYear as Integer
Dim strNewID as String

intMonth = DatePart("m", [YourBirthdayField])
intDay = DatePart("d", [YourBirthdayField])
intYear = DatePart("yyyy", [YourBirthdayField])
strNewID = "ID" & CStr(intMonth) & CStr(intDay) & Cstr(intYear)
' The result of strNewID would be 'ID04272006' if you ran this today


--
-D
Duncan Bachen
Director of I.T., Ole Hansen and Sons, Inc.
  #4  
Old April 28th, 2006, 03:30 AM posted to microsoft.public.access.forms
external usenet poster
 
Posts: n/a
Default how can I store short dates numbers only no slashes

On Thu, 27 Apr 2006 12:11:02 -0700, eleeiv
wrote:

I am triing to concatenate parts of cells to create ID numbers but the Date
of Birth stores slashes and puts them into my ID numbers


I'd step back and reconsider. Birthdates are not unique; many people
were born on May 16, 1946. Quite a few of them probably have the
initials JWV. Building an "Intelligent Key" such as jwv05161946 will
be possible, but a fair bit of work - and you have NO guarantee that
it will be unique or appropriate!

As a rule, one should NOT store multiple pieces of information in one
field. It's just a bad idea for many reasons.

John W. Vinson[MVP]
 




Thread Tools
Display Modes

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

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Show dates if multiple Serail numbers are equal Dark_Templar General Discussion 6 April 8th, 2006 06:09 AM
prevent converting numbers with hyphens to dates Mike General Discussion 5 January 27th, 2006 08:41 PM
numbers changing to dates technotronic General Discussion 6 January 18th, 2006 05:50 AM
reversing numbers to create dates Gilles Desjardins Worksheet Functions 5 October 4th, 2005 11:33 PM
prevent Excel from EVERautomatically converting numbers to dates gt Worksheet Functions 1 December 9th, 2003 10:01 PM


All times are GMT +1. The time now is 04:55 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.