PDA

Click to See Complete Forum and Search --> : Format a date


R@emdonck
Dec 12th, 1999, 11:22 AM
Hello,

How can I format a date ? the result must be
"dd/mm/yy"

for example:

Dim MyDate as Date

MyDate = Now()

The result is always "dd/mm/yy hh:mm:ss"

How can dump the "hh:mm:ss" ?

R@emdonck

MartinLiss
Dec 12th, 1999, 11:42 AM
Look up the Format function in Help. One of the "named" (built-in) formats for dates is Short Date and it's used like thisMsgBox Format(Now(), "Short Date")

------------------
Marty

QWERTY
Dec 12th, 1999, 11:42 AM
This seems to work:

Dim MyDate As Date
MyDate = Format(Now, "hh:mm:ss")


------------------
Visual Basic Programmer
------------------
PolComSoft
You will hear a lot about it.

Ruchi
Dec 12th, 1999, 12:34 PM
This uses the format string "m/d/yy", which displays the month, day, and a two-digit year.


Dim MyDate As Date
MyDate = Now()
Text1.Text = Format(MyDate, "m/d/yy")



[This message has been edited by Ruchi (edited 12-13-1999).]

funkheads
Dec 12th, 1999, 02:40 PM
here are many formats you can use:

d = one digit date
dd = two digit date
ddd = abbreviated day name
dddd = full day name

m - one digit month
mm = two digit month
mmm = abbreviated month name
mmmm = full month name

yy = two digit year
yyyy = four digit year

use any of those formats with wach other in this code:

Text1.Text = Format(MyDate, see above formats)

for instance...
Text1.Text = Format(MyDate, dd/mm/yy)
will return 27/01/99

or

Text1.Text = Format(MyDate, dddd mmm dd, yyyy)
will return Wednesday Jan 27, 1999

hope this all helps. happy programming!!

--michael