Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Fun with String conversions! (cDate function)

Hi All,

I've been seeing some consistantly bizzare behavior with the cdate function...

Many fields in my databases intended to store date information are string fields, with a common format.

Here's my formula that sucessfully converts these string fields into CDates.

stringvar strYear;
stringvar strMonth;
stringvar strDay;

//format of the date in the DB is YYYYMMDD_tttttt...
//extract the date portion

strInDate := left(strInDate, 8);

strYear := left(strInDate, 4);
strMonth := mid(strInDate, 5, 2);
strDay := mid(strInDate, 7, 2);

cdate(tonumber(strYear), tonumber(strMonth), tonumber(strDay));

Yay! now I have a date field that I can work with... here's where it gets wierd.

When I start using this date field (that displays correctly) that I get wierd behavior.

If I group based on this field, the values in the groups don't seems to corelate with the groups themselves, and it doesn't seem to follow any pattern or reason.

Some records are grouped with records from 'the past' and some 'the future', and I can't seem to figure out why...

Do I need to use whileprintingrecords or whilereadingrecords to get this to group properly?

Former Member
Not what you were looking for? View more on this topic or Ask a question