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

Format Date represent the Month and year in Visual Foxpro

Status
Not open for further replies.

mherz715

Programmer
Apr 4, 2012
17
0
0
PH
Hi!

I am just getting to start to know more about foxpro. I would like to know how to display a date represent a month and year only... something like this: "Jan2012"

Thanks in advance....
 
Code:
ldDate=DATE() && assign a date
lcOutText=CMONTH(m.ldDate)+" "+TRANSFORM(YEAR(m.ldDate))
? m.lcOutText

If you just want the shortened month name, use LEFT( CMONTH( m.ldDate), 3)


 
Keep in mind that, unlike what can occur to Date appearance in Excel cell formatting, if you do as above and display the NEW variable (lcOutText) things will appear as you want, but that new variable will not ITSELF contain a Date value. It will be a character string.

So any computations or evaluations you do will need to be against the variable holding the actual Date value (ldDate).
Code:
* Examples:
   dOneMonthFromNow = GOMONTH(ldDate,1)
   dSixMonthsAgo = GOMONTH(ldDate,-6)

   SELECT *;
      FROM MyTable;
      WHERE MyTable.Date <= ldDate;
      INTO CURSOR Results READWRITE
    etc.

Good Luck,
JRB-Bldr
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top