Connecting Tech Pros Worldwide Help | Site Map

Procedure Assistance Requested - Dates

 
LinkBack Thread Tools Search this Thread
  #1  
Old November 12th, 2005, 04:22 PM
Kenny G
Guest
 
Posts: n/a
Default Procedure Assistance Requested - Dates

I would like some assistance on writing a procedure.

I have a StartDate and an EndDate. If the EndDate is less than the
StartDate then I need to undo the input in the EndDate, let the user
know that the date is incorrect, and have the user put in the correct
date.

Thanks in advance.

Kenny G

  #2  
Old November 12th, 2005, 04:22 PM
Phil Stanton
Guest
 
Posts: n/a
Default Re: Procedure Assistance Requested - Dates

Private Sub ToDate_BeforeUpdate(Cancel As Integer)

Dim Date1 As Date, Date2 As Date
Date1 = Format$(FromDate, "mmm\/dd\/yyyy")
Date2 = Format$(ToDate, "mmm\/dd\/yyyy")

If DateDiff("d", Date1, Date2) < 0 Then
MsgBox "From date is after To Date by " & DateDiff("d", Date1,
Date2) & " days", vbCritical
Cancel = True
Else
MsgBox "To date is after From Date by " & DateDiff("d", Date1,
Date2) & " days", vbInformation
End If
End Sub

You need a similar thing before Update of thr FromDate

The formatting rubbish seems to get over the problem with we(The Brits)
having a less illogical date format than the Americans.
Also lots of unneccessary stuff in the message box, but it will allow you to
check the arithmetic

Phil


"Kenny G" <kg_321@hotmail.com> wrote in message
news:810d01a6.0312041203.5c960b5a@posting.google.c om...[color=blue]
> I would like some assistance on writing a procedure.
>
> I have a StartDate and an EndDate. If the EndDate is less than the
> StartDate then I need to undo the input in the EndDate, let the user
> know that the date is incorrect, and have the user put in the correct
> date.
>
> Thanks in advance.
>
> Kenny G[/color]


  #3  
Old November 12th, 2005, 04:24 PM
Kenny G
Guest
 
Posts: n/a
Default Re: Procedure Assistance Requested - Dates

Phil,

That worked out just fine. I appreciate your help. I did notice the
differences in dates on SQL server with the ways different countries
write their dates.

Thanks again, Kenny G

"Phil Stanton" <discussion@stantonfamily.co.uk> wrote in message news:<3fcfada1$0$99607$65c69314@mercury.nildram.ne t>...[color=blue]
> Private Sub ToDate_BeforeUpdate(Cancel As Integer)
>
> Dim Date1 As Date, Date2 As Date
> Date1 = Format$(FromDate, "mmm\/dd\/yyyy")
> Date2 = Format$(ToDate, "mmm\/dd\/yyyy")
>
> If DateDiff("d", Date1, Date2) < 0 Then
> MsgBox "From date is after To Date by " & DateDiff("d", Date1,
> Date2) & " days", vbCritical
> Cancel = True
> Else
> MsgBox "To date is after From Date by " & DateDiff("d", Date1,
> Date2) & " days", vbInformation
> End If
> End Sub
>
> You need a similar thing before Update of thr FromDate
>
> The formatting rubbish seems to get over the problem with we(The Brits)
> having a less illogical date format than the Americans.
> Also lots of unneccessary stuff in the message box, but it will allow you to
> check the arithmetic
>
> Phil
>
>
> "Kenny G" <kg_321@hotmail.com> wrote in message
> news:810d01a6.0312041203.5c960b5a@posting.google.c om...[color=green]
> > I would like some assistance on writing a procedure.
> >
> > I have a StartDate and an EndDate. If the EndDate is less than the
> > StartDate then I need to undo the input in the EndDate, let the user
> > know that the date is incorrect, and have the user put in the correct
> > date.
> >
> > Thanks in advance.
> >
> > Kenny G[/color][/color]
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,662 network members.