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!

Text/Data formula problem

Status
Not open for further replies.

michpaus

Programmer
Oct 18, 2005
11
US
I need to create a formula that will look at a field ( Expiry Date) and display items regardless of the data type. Unfortunately some of the dates were entered as date/time and others were entered as text. The report is pulling the information from a main frame database where dates are entered by end users.
I want te formula to say
If Expiry Date = text then display
else
If expiry date = date/time then display

Please help I am drawing a complete blank.
 
Data returned by a database is always the same, the format is the only thing that might change.

The first thing to do is right click the field and select browse data, this will tell you the field type (probably String).

Now use a formula to test it's validity, such as:

// assuming a format of YYYYDDMM HHMMSS
Stringvar MyDate := {table.field};
if val(left(MyDate,4)) < 2500
and
val(mid(MyDate,5,2)) in 1 to 12
and
val(mid(MyDate,7,2)) in 1 to 31
then
cdate(val(left(MyDate,4)),val(mid(MyDate,5,2)),val(mid(MyDate,7,2)))

You'll need other checks.

It would be best to get your dba to run tests and clean up from the database side.

-k
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top