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!

convert string to yyyy mm dd

Status
Not open for further replies.

rrmcguire

Programmer
Oct 13, 2010
304
US
Hello,

Im trying to convert a string which is written as 5/16/2005 to a date in the format yyyy mm dd.

So far Im using this syntax

dim str1 as string
dim strday as string
dim strmon as string
dim stryear as string
dim strdate as string
str1 = {Tractors_TTX.YEAR_PURCHASED}

stryear = left(str1,4)
strday = right(str1,2)
strmon = left(right(str1,4),2)

formula = stryear & strmon & strday


but its still showing month, day, year

any help would be appreciated.
 
maybe something like this?

//{@datereorder}
numbervar mo := tonumber(split({Tractors_TTX.YEAR_PURCHASED},"/")[1]);
numbervar da := tonumber(split({Tractors_TTX.YEAR_PURCHASED},"/")[2]);
numbervar yr := tonumber(split({Tractors_TTX.YEAR_PURCHASED},"/")[3]);

yr &" "& da &" "& mo

 

date("5/16/2005")

evaluates properly to a date, then you can format the date as yyyy mm dd
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top