I solved my problem with the issue of Julian date, but i have another small issue..

I have to use dates in calculation ... like a client types a appointment datat in textbox and in another textbox it shows that the date has to be between two days.
(appointment written in text box has to be 90 days after today but less than 100 days and also appointment cannot be not less than 80 of today)
I am really stuck here...I think I have to addDays of 90...but it will not let me use < less than or > greater than signs for dates..Do I have to format it first...not sure of it.

Here is part of my code that I've been working on

Private Sub btnConfirm_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnConfirm.Click

        Dim dteToday As Date = Today
        Dim aptDate As Date

        ' error if there is nothing typed in textbox
        ' puts focus back in txtApt textbox
        If txtApt.Text = "" Then
            lblOut.Text = "Must enter a date"
            txtApt.Focus()
            Exit Sub
        End If

        'Error checking for date format and if date is today 
        'or date passed already/sets focus back in txtApt textbox
        If IsDate(txtApt.Text) Then
            aptDate = CDate(txtApt.Text)
            If aptDate = dteToday Then
                lblOut.Text = "date entered is today"
            ElseIf aptDate < dteToday Then
                lblOut.Text = "date entered has passed"
            End If
        Else
            lblOut.Text = "not a valid date"
            txtApt.Focus()
            txtApt.SelectAll()
            Exit Sub
        End If

'stuck here in calculation...

        'appointment is  90 days after today but less than 100 days but not less than 80

        'labels that print out i need to use in an if statement to calculate dates
        'lblOut.Text = "confirmed" & aptDate.ToShortTimeString & "days until appointment"
        'lblOut.Text = "appointment must be between" & aptDate.ToShortDateString & " and " & aptDate.ToShortDateString

    End Sub

Thank you :icon_confused:

Recommended Answers

All 6 Replies

See if this helps.

MsgBox(Date.Now.AddDays(90).ToShortDateString)
        MsgBox(Date.Now.AddDays(-90).ToShortDateString)
commented: very helpful..thank you +0

I have to use dates in calculation ... like a client types a appointment datat in textbox and in another textbox it shows that the date has to be between two days.
(appointment written in text box has to be 90 days after today but less than 100 days and also appointment cannot be not less than 80 of today)

Hi,

I'm not that sure what you want about 100 days and 80 days, but here's a way how to do it with 90 days.

Dim ts As TimeSpan
                ts = aptDate.Subtract(dteToday)
            
                TextBox1.Text = "Confirmed:" & "  " & dteToday.AddDays(90) & " " & (", " & ts.Days & " " & "days until appointment")

I have one more dilemma with this code before I wrap it up...

in the code I have to add several error messages..I got 2 to work but I cant seem to get the rest to work. the error code are

1)day part must be numeric
2)day cannot exceed 365 days or less or equal to 1

3)Year part must be numeric
4)year must be 4 digits

I'm thinking in the array where the deliminator (-) add indexes that hold
year and day..then I can use them in the error messages.

Here is what I have so far..everything works except me adding those error messages.

Private Sub btnConvert_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnConvert.Click

        Dim julianDate As String
        Dim convertJulianDate() As String
        Dim returnDate As Date

        If txtJulian.Text = "" Or txtJulian.Text.IndexOf("-") = -1 Then
            lblOut.Text = "Julian date must have a dash"
            txtJulian.Focus()
            txtJulian.SelectAll()
            Exit Sub
        End If

        julianDate = txtJulian.Text

        convertJulianDate = julianDate.Split("-"c)

        Dim dt As New Date(CInt(convertJulianDate(1)), 1, 1)

        returnDate = dt.AddDays(CInt(convertJulianDate(0)) - 1)

        lblOut.Text = returnDate.ToShortDateString
    End Sub
End Class

Thank you
:icon_neutral:

oh forgot to tell you that I solved the other part of the code...but thank you very much..the feedback was very useful...Now working with Julian date..(how dreadful) after I thought I was done with this code. Could sure use some feedback on the issue of julian dates above..

Hi msqueen082,

It was no problem to help you with the other part of your code.

To avoid that other members will help you with your other problem: Julian dates.
You should first solved this thread and open another one with your Julian's dates problem.

Thanks in advance.

Sure...thank you

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.