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

date and time stamp 1

Status
Not open for further replies.

dpk136

MIS
Jan 15, 2004
335
US
In vb6 how do you create a date stamp that has the date and time... in the order like "1/12/2005 22:39:45". Thanks,
David

David Kuhn
------------------
 
Use the Now function. It will give you the date and time returned.

Garry B
 
But not necessarily in the format requested, since vbGeneral (the default format used by Now()) picks up its format from the Regional settings

One solution would be:

format(now,"dd/mm/yyyy hh:nn:ss")
 
Take a look on this, It might help

"""this two will get you the actual date and time of your computer
MyDate = str(date)
MyTime = Str(time)

"""here is how you can manipulate those strings and some others
Dim MyTime, MyDate, MyStr

"""""let's say that this are the results
MyTime = #17:04:23#
MyDate = #January 13, 2005#

' 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 13 2005".
' If format is not supplied, a string is returned.
MyStr = Format(13) ' Returns "13".

' User-defined formats.
MyStr = Format(5459.4, "##,##0.00") ' Returns "5,459.40".
MyStr = Format(334.9, "###0.00") ' Returns "334.90".
MyStr = Format(5, "0.00%") ' Returns "500.00%".
MyStr = Format("HELLO", "<") ' Returns "hello".
MyStr = Format("This is it", ">") ' Returns "THIS IS IT".



Hope it helps
Ep
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top