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

Date Conversion - Number to Date

Status
Not open for further replies.

lissa1974

Technical User
Joined
Mar 2, 2006
Messages
26
Location
GB
Hi there, sure this is easy but cannot nail it down. I have a field thats a number field (SQL & CR2008) that I need converting to a date. The field example is.....

200810

I need to be able to see that as a date. Using CDate converts it very badly, as it then shows the year as 2449 on every record!!!! So no idea what's going on there. I basically need it to be YYYYMM.

Thanks
 
You need to convert to text and then break into two strings

@Date

whileprintingrecords;

stringvar month;
stringvar Year;

year:= left(totext({yourdatenumberfield, 0,""), 4);
month:= right(totext({yourdatenumberfield, 0,""), 2);

year&"/"&month;

If your filed is a numeric string there is no need for the totext function.

year:= left({yourdatefield, 4);
month:= right({yourdatefield, 2);

Ian



 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top