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!

Converting text to a date field

Status
Not open for further replies.

seegers

IS-IT--Management
May 6, 2002
3
US
I am trying to make a report formula to use as a group by a date of birth field. The field is a text field so I can not create a formula to bring back date of births between a specific range. I tried the string function "cdate", but it did not work.

I am trying to create an if, then formula:
If {field name dob} in date (01/01/1977) to date (01/01/1983) then "18-25"
 
You have the syntax for the Date() function wrong. It has 3 arguments, all integers, year, month and day, with a comma separater.

Change your formula to:
If {field name dob} in date (1997,1,1) to date (1983,1,1) then "18-25" Software Support for Macola, Crystal Reports and Goldmine
dgilsdorf@mchsi.com
 
Since your field is NOT a date, you can't compare it to a date.

Convert the database field using the date function too. Now you can compare date to date, and set the grouping formula to whatever value you need.

TIP: If you're using a real SQL database, you can convert the field in the SQL using a SQL Expression which will yield better performance.

One part that isn't clear was:

" I can not create a formula to bring back date of births between a specific range"

Is that to mean within specific range, or ranges? If it's ranges, then the above is correct. If it's just one range, than limit your rows in the record selection criteria to minimize processing, you won't need a group because it's just one.

-k

-k kai@informeddatadecisions.com
 
What is the format of your "String date field", {field name dob}

Dgillz - your formula won't work since you are comparing a date filter to s string field...

Your dilema is to first figure out the for format of the date field itself.

Hopefully it is a simple "yyyymmdd" format...if it is then the problem is very simple since a "date" comparison is not necessary at all....simply convert the string to a number then the formula would look like this:

If tonumber({field name dob}) >= 19770101 or
tonumber({field name dob}) <= 19830101 then
&quot;18-25&quot;
else if.....(and so on...)

If the &quot;date string&quot; format is some other format then you have the option to convert to a numeric as in the above
form or convert it to a date.
JimBroadbent@Hotmail.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top