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!

Get year, month and day numbers

Status
Not open for further replies.

huytonscouser

Programmer
Oct 14, 2011
88
US
I want a formula to get current date, and then create or return a numbervar.

i currently have a field {SRMHOST.LASTDISCOVERYTIME} that returns 20,130,502
i use this and create then join them together with this formula.

stringvar myyear :=totext(year({SRMHOST.LASTDISCOVERYTIME}),0);
stringvar mymonth :=totext(month({SRMHOST.LASTDISCOVERYTIME}),0);
stringvar myday :=totext(day({SRMHOST.LASTDISCOVERYTIME}),0);




if len(mymonth) = 1 then mymonth := "0" + mymonth; //adding leading zero months 1-9
if len(myday) =1 then myday := "0" + myday; // adding leading zero days 1-9

tonumber(myyear+mymonth+myday);

I want to duplicate the above using CURRENTDATE.

Thanks
 
Change your original fromula

stringvar myyear :=totext(year({SRMHOST.LASTDISCOVERYTIME}),"00",0);
stringvar mymonth :=totext(month({SRMHOST.LASTDISCOVERYTIME}),"00",0);
stringvar myday :=totext(day({SRMHOST.LASTDISCOVERYTIME}),"00",0);


For currentdate do

totext(currentdate, "yy")
totext(currentdate, "MM")
totext(currentdate, "dd")

Ian
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top