PC Review


Reply
Thread Tools Rate Thread

date data type is not a date??

 
 
Phyllis
Guest
Posts: n/a
 
      22nd Apr 2010
Following is code I am running. I intend to compare two dates. One date
(orderrg.value) is from a spreadsheet and is defined as a type date. The
other date is the system date. However when I check to see if the
orderrg.value is a date via ISDATE, it fails. Following the code is the
prinout from the immediate window. It looks to me like it should be able to
recognize it as a date, but yet it doesn't. Does anyone have any ideas?


Private Sub Workbook_Open()

Dim wscommission As Worksheet
Dim nindex As Integer
Dim lastorder As Integer
Dim sheetname As String
Dim orderws As Worksheet
Dim orderrg As range

Set wscommission = ThisWorkbook.Worksheets("commission")
Application.Cursor = xlNorthwestArrow

'DETERMINE IF ANY ORDERS ARE READY TO APPLY TO COMMISSION

Debug.Print Date

lastorder = ThisWorkbook.Worksheets.count - 8 'sets ending range to 'the
last possible order
Debug.Print lastorder
For nindex = 3 To lastorder 'process 1st order thru the last order
sheetname = ThisWorkbook.Worksheets(nindex).Name 'set up the sheetname
Debug.Print sheetname
'Sheets(sheetname).Select
Debug.Print ActiveWorkbook.Sheets(sheetname).Tab.ColorIndex
'PROCESS THRU THE ORDERS WHOSE COLOR IS LIGHT GREEN (CARRIER HAS BEEN
ASSIGNED)
If ActiveWorkbook.Sheets(sheetname).Tab.ColorIndex = 35 Then
'IF THE ORDER'S DELV DATE IS LESS THAN THE CURRENT DATE; PROCESS IT
Set orderws = ThisWorkbook.Worksheets(sheetname)
Set orderrg = orderws.range("E24")
Debug.Print orderrg.Value
'Dorderdate = CDate(orderrg.Value)
' orderdate = orderrg.Value

If IsDate(Date) Then
If IsDate(orderrg.Value) Then
'include code to compare the dates once I get valid dates
Else
GoTo usererror
End If
Else
GoTo usererror
End If
Else
Exit Sub
End If
Next

usererror:
Debug.Print "date invalid"

End Sub


HERE IS THE DISPLAY FROM THE IMMEDIATE WINDOW
4/22/2010
3
D100001
35
2/29/2010
date invalid
 
Reply With Quote
 
 
 
 
Dave Peterson
Guest
Posts: n/a
 
      22nd Apr 2010
2010 isn't a leap year, so 2/29/2010 isn't a date.



Phyllis wrote:
>
> Following is code I am running. I intend to compare two dates. One date
> (orderrg.value) is from a spreadsheet and is defined as a type date. The
> other date is the system date. However when I check to see if the
> orderrg.value is a date via ISDATE, it fails. Following the code is the
> prinout from the immediate window. It looks to me like it should be able to
> recognize it as a date, but yet it doesn't. Does anyone have any ideas?
>
> Private Sub Workbook_Open()
>
> Dim wscommission As Worksheet
> Dim nindex As Integer
> Dim lastorder As Integer
> Dim sheetname As String
> Dim orderws As Worksheet
> Dim orderrg As range
>
> Set wscommission = ThisWorkbook.Worksheets("commission")
> Application.Cursor = xlNorthwestArrow
>
> 'DETERMINE IF ANY ORDERS ARE READY TO APPLY TO COMMISSION
>
> Debug.Print Date
>
> lastorder = ThisWorkbook.Worksheets.count - 8 'sets ending range to 'the
> last possible order
> Debug.Print lastorder
> For nindex = 3 To lastorder 'process 1st order thru the last order
> sheetname = ThisWorkbook.Worksheets(nindex).Name 'set up the sheetname
> Debug.Print sheetname
> 'Sheets(sheetname).Select
> Debug.Print ActiveWorkbook.Sheets(sheetname).Tab.ColorIndex
> 'PROCESS THRU THE ORDERS WHOSE COLOR IS LIGHT GREEN (CARRIER HAS BEEN
> ASSIGNED)
> If ActiveWorkbook.Sheets(sheetname).Tab.ColorIndex = 35 Then
> 'IF THE ORDER'S DELV DATE IS LESS THAN THE CURRENT DATE; PROCESS IT
> Set orderws = ThisWorkbook.Worksheets(sheetname)
> Set orderrg = orderws.range("E24")
> Debug.Print orderrg.Value
> 'Dorderdate = CDate(orderrg.Value)
> ' orderdate = orderrg.Value
>
> If IsDate(Date) Then
> If IsDate(orderrg.Value) Then
> 'include code to compare the dates once I get valid dates
> Else
> GoTo usererror
> End If
> Else
> GoTo usererror
> End If
> Else
> Exit Sub
> End If
> Next
>
> usererror:
> Debug.Print "date invalid"
>
> End Sub
>
> HERE IS THE DISPLAY FROM THE IMMEDIATE WINDOW
> 4/22/2010
> 3
> D100001
> 35
> 2/29/2010
> date invalid


--

Dave Peterson
 
Reply With Quote
 
Phyllis
Guest
Posts: n/a
 
      23rd Apr 2010
Thank you Dave,
boy do I feel stupid. I was so busy concentrating on what was wrong with
the date format that it never occured to me.

"Dave Peterson" wrote:

> 2010 isn't a leap year, so 2/29/2010 isn't a date.
>
>
>
> Phyllis wrote:
> >
> > Following is code I am running. I intend to compare two dates. One date
> > (orderrg.value) is from a spreadsheet and is defined as a type date. The
> > other date is the system date. However when I check to see if the
> > orderrg.value is a date via ISDATE, it fails. Following the code is the
> > prinout from the immediate window. It looks to me like it should be able to
> > recognize it as a date, but yet it doesn't. Does anyone have any ideas?
> >
> > Private Sub Workbook_Open()
> >
> > Dim wscommission As Worksheet
> > Dim nindex As Integer
> > Dim lastorder As Integer
> > Dim sheetname As String
> > Dim orderws As Worksheet
> > Dim orderrg As range
> >
> > Set wscommission = ThisWorkbook.Worksheets("commission")
> > Application.Cursor = xlNorthwestArrow
> >
> > 'DETERMINE IF ANY ORDERS ARE READY TO APPLY TO COMMISSION
> >
> > Debug.Print Date
> >
> > lastorder = ThisWorkbook.Worksheets.count - 8 'sets ending range to 'the
> > last possible order
> > Debug.Print lastorder
> > For nindex = 3 To lastorder 'process 1st order thru the last order
> > sheetname = ThisWorkbook.Worksheets(nindex).Name 'set up the sheetname
> > Debug.Print sheetname
> > 'Sheets(sheetname).Select
> > Debug.Print ActiveWorkbook.Sheets(sheetname).Tab.ColorIndex
> > 'PROCESS THRU THE ORDERS WHOSE COLOR IS LIGHT GREEN (CARRIER HAS BEEN
> > ASSIGNED)
> > If ActiveWorkbook.Sheets(sheetname).Tab.ColorIndex = 35 Then
> > 'IF THE ORDER'S DELV DATE IS LESS THAN THE CURRENT DATE; PROCESS IT
> > Set orderws = ThisWorkbook.Worksheets(sheetname)
> > Set orderrg = orderws.range("E24")
> > Debug.Print orderrg.Value
> > 'Dorderdate = CDate(orderrg.Value)
> > ' orderdate = orderrg.Value
> >
> > If IsDate(Date) Then
> > If IsDate(orderrg.Value) Then
> > 'include code to compare the dates once I get valid dates
> > Else
> > GoTo usererror
> > End If
> > Else
> > GoTo usererror
> > End If
> > Else
> > Exit Sub
> > End If
> > Next
> >
> > usererror:
> > Debug.Print "date invalid"
> >
> > End Sub
> >
> > HERE IS THE DISPLAY FROM THE IMMEDIATE WINDOW
> > 4/22/2010
> > 3
> > D100001
> > 35
> > 2/29/2010
> > date invalid

>
> --
>
> Dave Peterson
> .
>

 
Reply With Quote
 
Dave Peterson
Guest
Posts: n/a
 
      23rd Apr 2010
Sometimes, those kinds of errors just need an extra pair of eyes.

Phyllis wrote:
>
> Thank you Dave,
> boy do I feel stupid. I was so busy concentrating on what was wrong with
> the date format that it never occured to me.
>
> "Dave Peterson" wrote:
>
> > 2010 isn't a leap year, so 2/29/2010 isn't a date.
> >
> >
> >
> > Phyllis wrote:
> > >
> > > Following is code I am running. I intend to compare two dates. One date
> > > (orderrg.value) is from a spreadsheet and is defined as a type date. The
> > > other date is the system date. However when I check to see if the
> > > orderrg.value is a date via ISDATE, it fails. Following the code is the
> > > prinout from the immediate window. It looks to me like it should be able to
> > > recognize it as a date, but yet it doesn't. Does anyone have any ideas?
> > >
> > > Private Sub Workbook_Open()
> > >
> > > Dim wscommission As Worksheet
> > > Dim nindex As Integer
> > > Dim lastorder As Integer
> > > Dim sheetname As String
> > > Dim orderws As Worksheet
> > > Dim orderrg As range
> > >
> > > Set wscommission = ThisWorkbook.Worksheets("commission")
> > > Application.Cursor = xlNorthwestArrow
> > >
> > > 'DETERMINE IF ANY ORDERS ARE READY TO APPLY TO COMMISSION
> > >
> > > Debug.Print Date
> > >
> > > lastorder = ThisWorkbook.Worksheets.count - 8 'sets ending range to 'the
> > > last possible order
> > > Debug.Print lastorder
> > > For nindex = 3 To lastorder 'process 1st order thru the last order
> > > sheetname = ThisWorkbook.Worksheets(nindex).Name 'set up the sheetname
> > > Debug.Print sheetname
> > > 'Sheets(sheetname).Select
> > > Debug.Print ActiveWorkbook.Sheets(sheetname).Tab.ColorIndex
> > > 'PROCESS THRU THE ORDERS WHOSE COLOR IS LIGHT GREEN (CARRIER HAS BEEN
> > > ASSIGNED)
> > > If ActiveWorkbook.Sheets(sheetname).Tab.ColorIndex = 35 Then
> > > 'IF THE ORDER'S DELV DATE IS LESS THAN THE CURRENT DATE; PROCESS IT
> > > Set orderws = ThisWorkbook.Worksheets(sheetname)
> > > Set orderrg = orderws.range("E24")
> > > Debug.Print orderrg.Value
> > > 'Dorderdate = CDate(orderrg.Value)
> > > ' orderdate = orderrg.Value
> > >
> > > If IsDate(Date) Then
> > > If IsDate(orderrg.Value) Then
> > > 'include code to compare the dates once I get valid dates
> > > Else
> > > GoTo usererror
> > > End If
> > > Else
> > > GoTo usererror
> > > End If
> > > Else
> > > Exit Sub
> > > End If
> > > Next
> > >
> > > usererror:
> > > Debug.Print "date invalid"
> > >
> > > End Sub
> > >
> > > HERE IS THE DISPLAY FROM THE IMMEDIATE WINDOW
> > > 4/22/2010
> > > 3
> > > D100001
> > > 35
> > > 2/29/2010
> > > date invalid

> >
> > --
> >
> > Dave Peterson
> > .
> >


--

Dave Peterson
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Text type date change to date type date Chrissy Microsoft Access 2 28th Apr 2009 06:17 PM
i have two date fileds Opend date Due date, can i set default on due date so, its always = to open date on my data entry form1 Urgent Mike Saifie Microsoft Access Form Coding 1 9th Mar 2006 01:08 AM
Between [high date] and [low date] formula using Data Type: Text =?Utf-8?B?a2luZ3MxMDA1MjQ=?= Microsoft Access Queries 2 10th Nov 2005 10:28 PM
date data type =?Utf-8?B?QW5u?= Microsoft Access Form Coding 1 16th Nov 2004 03:32 PM
Convert a string containing a 32-bit binary date to a date data type Remi Caron Microsoft C# .NET 2 22nd Sep 2004 06:23 PM


Features
 

Advertising
 

Newsgroups
 


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