Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 20
Default What is the differance between cdate and ...

I had this in my code
ActiveCell.Offset(0, 8) = CDate(TextBox_Attempt1Date)
and I wanted to include the time as well and changed it to
ActiveCell.Offset(0, 8) = TextBox_Attempt1Date

Now when i evaluate the cell<today() , I am always getting true, even if the
value from yesterday is in the cell.

How should I code this so that I get the date and time, but also so that the
comparison with today() provides valid results?

Thnaks
Bruce


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default What is the differance between cdate and ...

No reason not to use cdate:

? typename(cdate("01/01/2003 10:53 AM"))
Date
? cdate("01/01/2003 10:53 AM")
1/1/2003 10:53:00 AM


Regards,
Tom Ogilvy

"Bruccce" wrote in message
news:NOvYa.88848$uu5.12702@sccrnsc04...
I had this in my code
ActiveCell.Offset(0, 8) = CDate(TextBox_Attempt1Date)
and I wanted to include the time as well and changed it to
ActiveCell.Offset(0, 8) = TextBox_Attempt1Date

Now when i evaluate the cell<today() , I am always getting true, even if

the
value from yesterday is in the cell.

How should I code this so that I get the date and time, but also so that

the
comparison with today() provides valid results?

Thnaks
Bruce




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 20
Default What is the differance between cdate and ...

When I use cdate(TextBox_Attempt1Date) is only has the date, not the time.
where TextBox_Attempt1Date has the date AND time. Is there a setting that
controls cDate()?

Bruce

"Tom Ogilvy" wrote in message
...
No reason not to use cdate:

? typename(cdate("01/01/2003 10:53 AM"))
Date
? cdate("01/01/2003 10:53 AM")
1/1/2003 10:53:00 AM


Regards,
Tom Ogilvy

"Bruccce" wrote in message
news:NOvYa.88848$uu5.12702@sccrnsc04...
I had this in my code
ActiveCell.Offset(0, 8) = CDate(TextBox_Attempt1Date)
and I wanted to include the time as well and changed it to
ActiveCell.Offset(0, 8) = TextBox_Attempt1Date

Now when i evaluate the cell<today() , I am always getting true, even if

the
value from yesterday is in the cell.

How should I code this so that I get the date and time, but also so that

the
comparison with today() provides valid results?

Thnaks
Bruce






  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default What is the differance between cdate and ...

As I demonstrated, it has the time as well if the text string has the time.
I suspect you need to format the cell to show the time.

Today at noon would look like

? cdbl(cdate(date+timevalue("12:00")))
37840.5

If I put this in a cell

Range("B9").Value = cdate(date+timevalue("12:00"))
? range("B9").Text
8/7/2003 12:00
' but if I format the cell to just show date
Range("B9").NumberFormat = "mm/dd/yyyy"
? range("B9").Text
08/07/2003
' however, the time is still stored in the cell
? range("B9").Value
8/7/2003 12:00:00 PM

I suspect you are seeing formatted output and not look at what is actually
stored in the cell.

Regards,
Tom Ogilvy


"Bruccce" wrote in message
news:R1xYa.90594$YN5.64744@sccrnsc01...
When I use cdate(TextBox_Attempt1Date) is only has the date, not the time.
where TextBox_Attempt1Date has the date AND time. Is there a setting that
controls cDate()?

Bruce

"Tom Ogilvy" wrote in message
...
No reason not to use cdate:

? typename(cdate("01/01/2003 10:53 AM"))
Date
? cdate("01/01/2003 10:53 AM")
1/1/2003 10:53:00 AM


Regards,
Tom Ogilvy

"Bruccce" wrote in message
news:NOvYa.88848$uu5.12702@sccrnsc04...
I had this in my code
ActiveCell.Offset(0, 8) = CDate(TextBox_Attempt1Date)
and I wanted to include the time as well and changed it to
ActiveCell.Offset(0, 8) = TextBox_Attempt1Date

Now when i evaluate the cell<today() , I am always getting true, even

if
the
value from yesterday is in the cell.

How should I code this so that I get the date and time, but also so

that
the
comparison with today() provides valid results?

Thnaks
Bruce








Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Using Rank with ties and spliting the differance assws Excel Discussion (Misc queries) 6 July 29th 05 03:09 PM
Formula for finding the differance between two times DP01 Excel Worksheet Functions 1 April 4th 05 01:57 AM


All times are GMT +1. The time now is 11:15 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"