Discussion Locked

Foxpro

0 helpful
5 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

Hi there,

I am trying to retrieve a substring of a date field using the DTOC function and the SUBSTR function and I cannot get them to work together.

The field is defined as a date field, and I want to retreive just the year protion. EX: 03/01/97

I cannot find any syntax that will work. If I covert the field in the database to a CHAR field for all the records the SUBSTR will work just fine. If I use the DTOC in conjunction with the SUBSTR it will not work. If anyone can give me an example of how to code this I would be very happy.

TIA
Robert Payne

5 replies

by otl

Try;

Store substr(dtoc(fieldname),7,2) to variable

This would return 97 as text and store it to your variable

This discussion is closed to new replies.