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

Problem with Dates in Excel 2

Status
Not open for further replies.

turps

Instructor
Jan 11, 2005
36
FR
Hi

I have a form that allows the use to click on a button to input the date and time. This then needs to be added to a worksheet and need to display the date and the time within the same cell. Using the code

Code:
ActiveSheet.Range("A1").Value = DateValue(txtDate.Text)

this works with the date but displays it as 00:00 for the time. The time I need to use is the time that the user inputs not the time on the PC. How can I add the time function to this line of code?


Regards

David

 

Hi,

Try also using the TimeValue function.

Skip,

[glasses] [red]Be Advised![/red] The Vinyards of Texas have produced a wine with diuretic dimishment...
Pinot More![tongue]
 
Hi

I have got it to work by
Code:
deadlinetime = Right(txtDeadline, 5)
    Cells(srow, 5) = DateValue(frmCheckers.txtDeadline.Text) & " " & deadlinetime



Regards

David

 


You could add the DateValue and the TimeValue to be more consistent.

Did you read...

Why do Dates and Times seem to be so much trouble? faq68-5827

Skip,

[glasses] [red]Be Advised![/red] The Vinyards of Texas have produced a wine with diuretic dimishment...
Pinot More![tongue]
 
...and why not:

ActiveSheet.Range("A1").Value = DateValue(txtDate.Text) + TimeValue(txtDate.Text)

Rgds, Geoff

We could learn a lot from crayons. Some are sharp, some are pretty and some are dull. Some have weird names and all are different colours but they all live in the same box.

Please read FAQ222-2244 before you ask a question
 


EXACTLY!

Skip,

[glasses] [red]Be Advised![/red] The Vinyards of Texas have produced a wine with diuretic dimishment and urethric relief...
Pinot More![tongue]
 
...well - if you only pick up the Date Value, you can hardly be surprised when you get nothing for the time ;-)

Rgds, Geoff

We could learn a lot from crayons. Some are sharp, some are pretty and some are dull. Some have weird names and all are different colours but they all live in the same box.

Please read FAQ222-2244 before you ask a question
 
Thank you all for your help

[Thumbsup]

Regards

David

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top