How to seperate MM/DD/YY into seperate fields in access 
Author Message
 How to seperate MM/DD/YY into seperate fields in access

The easiest way that I know of is to use the left, mid and right functions.

for example to get MM it would be strMM = Left(datDate, 2)
to get the DD it would be strDD = Mid(datDate,3,2)
to get the YY it would be strYY = Right(datDate,2)


Quote:
> Ok, I know this has got to be simple. All I need to do is take an existing
> date in the MM/DD/YY format and seperate it into fields for month, day,
> and year. I'm new to VB and I'm trying to fix a Y2K Date bug with a
> Microsoft Access 2000 database. I don't know how to make a loop statement
> to delimit the data at the /'s.  Any help would be greatly appreciated.

> Thanks,

> JDK

> --
> Posted via CNET Help.com
> http://www.*-*-*.com/



Sat, 25 May 2002 03:00:00 GMT  
 How to seperate MM/DD/YY into seperate fields in access
Ok, I know this has got to be simple. All I need to do is take an existing
date in the MM/DD/YY format and seperate it into fields for month, day,
and year. I'm new to VB and I'm trying to fix a Y2K Date bug with a
Microsoft Access 2000 database. I don't know how to make a loop statement
to delimit the data at the /'s.  Any help would be greatly appreciated.

Thanks,

JDK

--
Posted via CNET Help.com
http://www.help.com/



Sun, 26 May 2002 03:00:00 GMT  
 How to seperate MM/DD/YY into seperate fields in access

Quote:

> The easiest way that I know of is to use the left, mid and right functions.

> for example to get MM it would be strMM = Left(datDate, 2)
> to get the DD it would be strDD = Mid(datDate,3,2)
> to get the YY it would be strYY = Right(datDate,2)

  Hmmm...the above may not get the expected result if the date variable
is formatted as Short Date or Long Date (except for getting the 2 digits
of year with Right function).  Might be more certain to get exactly the
result you want by picking from the following, to suit your desired
result format:

  strMonth = Format(datDate, "m") 'to return e.g. 8 or 11
  strMM = Format(datDate, "mm") 'to return e.g. 08 or 11
  strDay = Format(datDate, "d") 'to return e.g. 8 or 11
  strDD = Format(datDate, "dd") 'to return e.g. 08 or 11
  strYY = Format(datDate, "yy") 'to return e.g. 99 or 00
  strYear = Format(datDate, "yyyy") 'to return e.g. 1999 or 2000
--
Jim in Cleveland
If you're writing to me, in my address
change "REAL_Address.see.below" to "worldnet.att.net"

"What's so funny 'bout peace, love & understanding?"
     - Nick Lowe



Sun, 26 May 2002 03:00:00 GMT  
 How to seperate MM/DD/YY into seperate fields in access
On Wed, 08 Dec 1999 00:06:49 -0500, Jim in Cleveland

Quote:

>  strMonth = Format(datDate, "m") 'to return e.g. 8 or 11
>  strMM = Format(datDate, "mm") 'to return e.g. 08 or 11
>  strDay = Format(datDate, "d") 'to return e.g. 8 or 11
>  strDD = Format(datDate, "dd") 'to return e.g. 08 or 11
>  strYY = Format(datDate, "yy") 'to return e.g. 99 or 00
>  strYear = Format(datDate, "yyyy") 'to return e.g. 1999 or 2000

What is wrong with the time-honoured functions?

  wDay = Day(dtMyDate)
  wMonth = Month(dtMyDate)
  wYear = Year(dtMyDate)

..?

Tim F

--



Sun, 26 May 2002 03:00:00 GMT  
 How to seperate MM/DD/YY into seperate fields in access
Thanks for all the help guys.
Tim, nothing is wrong with using the

wDay = Day(dtMyDate)
wMonth = Month(dtMyDate)
wYear = Year(dtMyDate)

functions when using a solely VB program. However, in access I have had
problems with it when I converted the DB from Access 97 format to Access
2000. Thats why the problem originated. I didn't origianlly make the
Database and I guess he didn't take into consideration Y2K. I could only
make a temporary fix until I learned another way of making it work. I'm
not really sure why it quit working, but it would lock up consitantly
until I removed that specific code. So, in otherwords I'm still learning
VB, and am still trying to figure the in's and out's.

Again thanks for all the input on this.

JDK

Quote:

> On Wed, 08 Dec 1999 00:06:49 -0500, Jim in Cleveland

> >  strMonth = Format(datDate, "m") 'to return e.g. 8 or 11
> >  strMM = Format(datDate, "mm") 'to return e.g. 08 or 11
> >  strDay = Format(datDate, "d") 'to return e.g. 8 or 11
> >  strDD = Format(datDate, "dd") 'to return e.g. 08 or 11
> >  strYY = Format(datDate, "yy") 'to return e.g. 99 or 00
> >  strYear = Format(datDate, "yyyy") 'to return e.g. 1999 or 2000

> What is wrong with the time-honoured functions?

>   wDay = Day(dtMyDate)
>   wMonth = Month(dtMyDate)
>   wYear = Year(dtMyDate)

> ..?

> Tim F

> --


--
Posted via CNET Help.com
http://www.help.com/


Sun, 26 May 2002 03:00:00 GMT  
 How to seperate MM/DD/YY into seperate fields in access

Quote:

>using a solely VB program. However, in access I have had
>problems with it when I converted the DB from Access 97 format to Access
>2000.

These functions are certainly present and functional in A97, and I
find it hard to believe that they've been withdrawn from A2000 VBA.
Have you checked the setup, and looked for any missing References?

Quote:
> it would lock up consitantly
>until I removed that specific code.

Hmm:- I'd be suspicious of the set up, a broken DLL or something. Or
is this a recognised problem with A2000?

Tim F

--



Mon, 27 May 2002 03:00:00 GMT  
 How to seperate MM/DD/YY into seperate fields in access

Quote:
> for example to get MM it would be strMM = Left(datDate, 2)
> to get the DD it would be strDD = Mid(datDate,3,2)
> to get the YY it would be strYY = Right(datDate,2)

 That's the perfect to make a European crazy if he uses this program, as
the date format is "dd/mm/yyyy" in many countries.

 I've learned to use Day(), Month(), Year(), and NEVER play with dates
as strings (except for input/output ; and I use the Format function (and
field properties in Access))

--
Christophe Courtois

http://www.christophe.courtois.org
--
Lois de Murphy de l'entreprise : Loi de De La Lastra

 Apres que les 16 vis aient ete enlevees d'un panneau d'acces,
 on decouvrira qu'il s'agissait du mauvais panneau d'acces.



Tue, 28 May 2002 03:00:00 GMT  
 How to seperate MM/DD/YY into seperate fields in access

Quote:

> These functions are certainly present and functional in A97, and I
> find it hard to believe that they've been withdrawn from A2000 VBA.
> Have you checked the setup, and looked for any missing References?

> > it would lock up consitantly
> >until I removed that specific code.

> Hmm:- I'd be suspicious of the set up, a broken DLL or something. Or
> is this a recognised problem with A2000?

The set up is good, I tested it on several computers on our network before
giving up. It works great in A97, but when I went through the conversion
process it stopped working. That function works in A2000, but for some
reason it didn't convert nicely. We're talking about a 60meg access
database, so a lot could have happened.
JDK

--
Posted via CNET Help.com
http://www.help.com/



Wed, 29 May 2002 03:00:00 GMT  
 
 [ 8 post ] 

 Relevant Pages 

1. date format dd/mm/yy instead of mm/dd/yy

2. converting dd/mm/yy to mm/dd/yy

3. How to get dd/mm/yy rather than mm/dd/yy

4. wrong date format : mm/dd/yy instead of dd/mm/yy

5. Change MDB Date field from mm/dd/yy to mm/dd/ccyy

6. MSFlexgrid date formats mm/dd/YY or mm/dd/YYYY

7. DATEVALUE and CDATE switch from mm/yy to mm/dd + (/thisyr)

8. Changing the week number to a date mm/dd/yy

9. Date Validation for UK format (DD/MM/YY)

10. Help: Enforce Date formate to MM-DD-YY?

11. Validating a date in dd/mm/yy format

12. listbox sorted with mm/dd/yy dates

 

 
Powered by phpBB® Forum Software