Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 74
Default Incorrect Date Returned

Hi

I have a cell which is in text format. The cell is referenced as a string. I
then need to check to see if the entered date/number entered into the cell is
before todays date.

I use the following code to change the format of the cell number/date to
become an actual date however the wrong date is shown.

rngFromC = 281006

stFromaDateNameC = rngFromC

If stFromDateNameC <= 999999 Then
stFromDateNameC = Format(stFromDateNameC, "mm/dd/yy")
stFromDateNameC = DateValue(stFromDateNameC)
End If

when converted into date format it shows 13/05/1969

I dont understand why it doesn't show as 28/10/06.

Any idea's

Thanks
Noemi

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default Incorrect Date Returned

You should use Option Explicit, you have different variable names in that
code, stFromDateNameC and stFromaDateNameC.

Try this instead

rngFromC = DateSerial(28, 10, 6)

stFromDateNameC = rngFromC

If stFromDateNameC <= 999999 Then
stFromDateNameC = Format(stFromDateNameC, "mm/dd/yy")
End If


--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"Noemi" wrote in message
...
Hi

I have a cell which is in text format. The cell is referenced as a string.

I
then need to check to see if the entered date/number entered into the cell

is
before todays date.

I use the following code to change the format of the cell number/date to
become an actual date however the wrong date is shown.

rngFromC = 281006

stFromaDateNameC = rngFromC

If stFromDateNameC <= 999999 Then
stFromDateNameC = Format(stFromDateNameC, "mm/dd/yy")
stFromDateNameC = DateValue(stFromDateNameC)
End If

when converted into date format it shows 13/05/1969

I dont understand why it doesn't show as 28/10/06.

Any idea's

Thanks
Noemi



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
returned calculation incorrect Gotroots Excel Worksheet Functions 6 November 6th 09 03:49 PM
IF/COUNT/AVERAGE... Value returned is incorrect. Rebekah Excel Worksheet Functions 3 September 28th 07 04:25 PM
Using COS in VBA, incorrect value returned Gnrnr Excel Worksheet Functions 5 September 19th 07 01:20 PM
I need today's date returned as date format in formula CMIConnie Excel Discussion (Misc queries) 2 February 23rd 06 04:38 PM
Value returned from Formula changes with the Date Jeff Excel Worksheet Functions 6 December 29th 05 02:48 AM


All times are GMT +1. The time now is 02:14 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"