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

Date to String in VBA

Status
Not open for further replies.

aabob

MIS
Sep 21, 2001
3
US
Pardon the newbie question, but how do I convert a date to a string in my VBA code for the purpose of evaluation?

Foxpro uses 'DTC' but I can find the VBA way.

Thanks.
 
I think maybe cStr,
although when I haven't got access/vba in front of me my mind goes blank and I tend to give wrong answers.

Nick
 
Syntax
Format(expression[, format[, firstdayofweek[, firstweekofyear]]])

'***********************************************************************
Dim MyTime, MyDate, MyStr
MyTime = #17:04:23#
MyDate = #January 27, 1993#

' Returns current system time in the system-defined long time format.
MyStr = Format(Time, "Long Time")

' Returns current system date in the system-defined long date format.
MyStr = Format(Date, "Long Date")

MyStr = Format(MyTime, "h:m:s") ' Returns "17:4:23".
MyStr = Format(MyTime, "hh:mm:ss AMPM") ' Returns "05:04:23 PM".
MyStr = Format(MyDate, "dddd, mmm d yyyy") ' Returns "Wednesday, Jan 27 1993"


ide
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top