Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Getting Computers Date & Time

Posted on 2000-02-22
7
142 Views
Last Modified: 2010-05-02
Hi,
I was wondering if anyone could help me.
      I want to know how to get the current computer time and date,
in both 24 hr format or showing "AM/PM"


Thanks
Dave Steers
0
Comment
Question by:dsteers
7 Comments
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 2548741
Use the Format function.

? format(time,"hh:nn:ss AMPM")
09:50:33 PM
? format(time,"hh:nn:ss")
21:50:47
0
 

Accepted Solution

by:
soosairaj earned 50 total points
ID: 2549037
Dear friend you can use  Now() function for both Date And Time .
 if you want only time you can use Time()
   if you want only  date you can use Date() function


Regards..

Raj
0
 
LVL 5

Expert Comment

by:KDivad
ID: 2549111
Date, Time and Now are probably what you want, but also take a look at the following functions: Year, Month, Day, Hour, Minute and Second.
0
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 

Author Comment

by:dsteers
ID: 2563701
Thank you everyone,soosairaj,emoreau &
KDavid.
0
 

Author Comment

by:dsteers
ID: 2563707
Also does anyone know a bit of code that would allow the subtraction of time over midnight.
E.g From 1300 (PM) Thursday 9 March to
 0200 (AM) Friday 10 March.

The Code will tell the difference between the two in days,hours & minutes.

Thanks
Dave Steers
0
 

Author Comment

by:dsteers
ID: 2563718
DAMM !!
I meant to Give the points to emoreau,
(sorry soosairaj).
My mistake.

emoreau I will post you the points in another question labled
"Points for emoreau"
sorry for this inconvienience.
Thanks
0
 
LVL 5

Expert Comment

by:KDivad
ID: 2564136
>>Also does anyone know a bit of code that would allow the subtraction of time over midnight.<<
Take a look at the DateDiff function.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question