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

Using Word datatype 2

Status
Not open for further replies.

lespaul

Programmer
Feb 4, 2002
7,083
US
I found this thread102-861091 where Andrew says:
towerbase said:
It (YearOf) returns a Word which can usually be used when an integer is required.

What if I need it to be a string? I'm having real difficulty getting the Word converted into a string.

Basically I need to get the current year and append a day & month to it:

CurrentYear + '0630' = '20070630'

Any suggestions?

thanks!
Leslie
 
you can use formatdatetime :

Str := FormatDateTime('YYYY0630');

/daddy

-----------------------------------------------------
What You See Is What You Get
Never underestimate tha powah of tha google!
 
worked great! (after I added the additional parameter!)

Code:
FilterString := FilterString + QuotedStr(FormatDateTime('YYYY0630', Today));

 
Yeah, sorry, doing this from memory :)

-----------------------------------------------------
What You See Is What You Get
Never underestimate tha powah of tha google!
 
no problem, I knew what you were trying to do....I just didn't know you could do it like that....thanks again!

leslie
 
To go more to the original question, something like IntToStr(Integer(WordValue)) should suffice, I would think.
 
Glenn, slightly simpler is:
Code:
IntToStr( WordValue );

Les, an alternative might be:
Code:
FilterString := Format( '%s%d0630', [ FilterString, YearOf(Today) ] );
I am not sure if this is easier to understand / maintain than your version.

Andrew
Hampshire, UK
 
Definitely. Done from memory, and strict-type checking in mind too (been going through some old Turbo Pascal things and having to correct word-integer things).
 
Thanks Andrew, I like that and can actually understand it too!

Les
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top