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

Convert number to a readable date 3

Status
Not open for further replies.

sugabutt

Technical User
Jan 3, 2009
16
US
I think I need to use an array for this, but I really am clueless on how to start it.

I have a field called date, but it actually looks like this (just an example): 1090812. I want to display as August 12, 2009 on the report. How do I setup a formula to look at the 2nd and 3rd position for the year, and if it says 09, then display 2009? And if the 4th and 5th are 08, then display August?

Thanks for your help.
 
stringvar x := totext({table.number},0,"");
date(2000+val(mid(x,2,2)),val(mid(x,4,2)),val(right(x,2)));

Then you can right click on the formula and format this date however you like.

-LB
 
Thanks lbass, that worked great. Now I have another question, but I will start a new thread for that.
 
Lbass,

I hate to bring up an old topic, but you've helped me so much in the past.

I have a similar problem and have read through a couple of posts to try to see if I'm missing something.

My date comes across 20090820

I've tried these two formulas:

stringvar x := totext({PXSTYL00.PXDCR},0,"");
Date(left(x,4),mid(x,4,2),right(x,2))

I get the error "Too Many Arguments Have been given to thsi funtion". It then highlights the mid section on.

and

stringvar x := totext({PXSTYL00.PXDCR},0,"");
Dateserial(left(x,4),mid(x,4,2),right(x,2))

This gives me the error a number is requiered here and highlights just the left part of my dateserial function.

Again, I apologize for having to bring this up again. I do, however, appreciate your help.

Thanks,
Ryan
 
If your date is a number then the formula should be:

stringvar x := {table.numberdate};
Date(val(left(x,4)),val(mid(x,5,2)),val(right(x,2)))

-LB
 
When I input this data, it comes and highlights my table and says that a string is required here.

Thanks,
Ryan
 
Edit to the above, I did put a totext and that seemed to work. A few more wrinkles to iron out but I believe I can figure it out.

Thanks,
Ryan
 
Sorry, that should have been:

stringvar x := totext({table.numberdate},0,"");
Date(val(left(x,4)),val(mid(x,5,2)),val(right(x,2)))

-LB
 
Much appreciated Lbass. You've helped me so many times. You don't know how much I appreciate it!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top