Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Datepart function

Status
Not open for further replies.

DirtDawg

IS-IT--Management
Apr 17, 2002
218
JP
Using the date part function, I am import information from another program. the date comes in the following format 20021012 or yyyymmdd, and now the datpart function is not working. Any ideas on how to fix this problem? there are to many dates to be changed manually.
 
So it's a number (or a text) that you need to convert to a date.

ConvertedToDate = DateValue(Format(Mid(YourField,5,2),"mmm") & " " & Right(YourField,2) & ", " & left(YourField, 4))

After you convert the values to dates, you'll be able to use DatePart.

Good luck,

[pipe]
Daniel Vlas
Systems Consultant
danvlas@yahoo.com
 
The date field is in numbers. from 20021012 i would like it to be changed into 10/12/2002. My date part function is to change the date into the week number.
 
Use the expression I posted. If you have any trouble, replace YourField with Str(YourField), where YourField is the name of that particular field in the table.

But I think it will work as posted.

Good luck
[pipe]
Daniel Vlas
Systems Consultant
danvlas@yahoo.com
 
everytime I am using this function I am getting a type mismatch. On the table I have one column for Date and one for the Week. I have the column date set for number, so that when I enter 20021025 it will understand, do I have to create a second column for the proper date to show 10/25/2002, sorry for basic question? The DatePart function will only convert the date to ww in my week column if it is in 10/25/2002.
 
Here is the formula I have

adate = CVDate(Format(Mid(adate, 5, 2), "mm") & " " & Right(adate, 2) & ", " & Left(adate, 4))

now when the date is 20021015

It is formatting it into 1/15/2002 I can not get it to have the months 10-12. Is there a reason why?

It is now working except for this one small part.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top