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!

date function

Status
Not open for further replies.

maddy41

Programmer
Dec 7, 2004
13
GB
I have this nearly working however i want to change date from dd\mm\yyyy to dd\mmm\yyyy
the bit that dosnt work is if the day is a single number then it shows d\mmm\yyyy i want to add 0 to meet format dd\mmm\yyyy
any help thanx

CODE SO FAR
________________________________________________________
FUNCTION ConvertDate
PARAMETERS dob
LOCAL d,m,y
d = DAY(dob)
m = CMONTH(dob)
m = SUBSTR(m,1,3)
y = YEAR(dob)

messagebox (ALLTRIM(STR(d))+"/"+ALLTRIM(m)+"/"+ALLTRIM(STR(y)))
 
You need the PADL() function:

Code:
messagebox (PADL(ALLTRIM(STR(d)),2,'0')+"/"+ALLTRIM(m)+"/"+ALLTRIM(STR(y)))

I like work. It fascinates me. I can sit and look at it for hours...
 
or add it to your function and remove it from the MESSAGEBOX():

Code:
d = PADL(ALLTRIM(STR(DAY(dob))),2,'0')


I like work. It fascinates me. I can sit and look at it for hours...
 
Code:
dob = Date(2005,1,1) && test date
d = PADL(TRANSFORM(DAY(dob)),2,"0")
m = LEFT(CMONTH(dob),3)
y = TRANSFORM(YEAR(dob))
   
messagebox (d+"/"+m+"/"+y)

Bye, Olaf.
 
Thanx for fix
i used dob = Date(2005,1,1) && test date
d = PADL(TRANSFORM(DAY(dob)),2,"0")
m = LEFT(CMONTH(dob),3)
y = TRANSFORM(YEAR(dob))

messagebox (d+"/"+m+"/"+y)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top