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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

getting the first two digits and middle digits and last 4 digits. 1

Status
Not open for further replies.

Neozero

MIS
Jul 7, 2000
49
0
0
US
I am trying to create a formula to chop up a date into seperate columns. I am using the LEFT (field name,2) and it is asking me for a string. What am I doing wrong? Also, what I am trying to do is pull the the first two digits from a date and then I want to create a formual to pull the middle 2 digits from the date and then another formula to pull the last 4 digits. so I can have individual columns for the dates. EX... change 06/07/2003 to show as three different columns. I know I would use the LEFT for the first two and use RIGHT for the last 4, but how do I get the middle two? This is where I am hitting the wall......
 
The reason for the error is because you are trying to use a string function on a date.

For your fields you can use:
totext(year({your.field}),"00")
and
totext(month({your.field}),"00")
and
totext(day({your.field}),"00")

To bust out using the left, right, or mid you'll need to change the date into a string.

For the month
left(totext({your.field],"MM/dd/yy"),2)
For the year
right(totext({your.field],"MM/dd/yy"),2)
For the day
mid(totext({your.field],"MM/dd/yy"),4,2)


Mike
 
mBarron - I like your first way better

Simply use

For the month Totext(month({table.date},"00")
For the day Totext(day({table.date},"00")
for the year Totext(year({table.date},"0000")

very simple



Jim Broadbent
 
You don't need to use any formula, just place the date field 3 times, right click it and select format field->Date/Time
->Customize->Date and set the Month Day and Year to None where appropriate.

-k
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top