Re: [2005] Comparing Dates
have another look at your code
vb Code:
If dtpDate.Value >= dateThirty And dtpDate.Value <= dateThirty Then
that'll never be executed. it can't be >= and <= at the same time unless its =
Re: [2005] Comparing Dates
Quote:
Originally Posted by .paul.
have another look at your code
vb Code:
If dtpDate.Value >= dateThirty And dtpDate.Value <= dateThirty Then
that'll never be executed. it can't be >= and <= at the same time unless its =
still the same output sir..
changed this one:
If dtpDate.Value >= dateThirty And dtpDate.Value <= dateThirty
to:
If dtpDate.Value = dateThirty And dtpDate.Value <= dateThirty
also the rest..
Re: [2005] Comparing Dates
try this
vb Code:
Dim tempDate As DateTime = dtpDate.Value
Dim dateThirty As Date = tempDate.AddDays(30)
Dim dateSixty As Date = tempDate.AddDays(60)
Dim dateNinety As Date = tempDate.AddDays(90)
Dim oneToThirtyAmount As New Integer
Dim thirtyToSixtyAmount As New Integer
Dim sixtyToNinetyAmount As New Integer
Dim moreThanNinetyAmount As New Integer
If dtpDate.Value >= tempDate And dtpDate.Value <= dateThirty Then
oneToThirtyAmount = txtAmount.Text
thirtyToSixtyAmount = 0
sixtyToNinetyAmount = 0
moreThanNinetyAmount = 0
ElseIf dtpDate.Value > dateThirty And dtpDate.Value <= dateSixty Then
oneToThirtyAmount = 0
thirtyToSixtyAmount = txtAmount.Text
sixtyToNinetyAmount = 0
moreThanNinetyAmount = 0
ElseIf dtpDate.Value > dateSixty And dtpDate.Value <= dateNinety Then
oneToThirtyAmount = 0
thirtyToSixtyAmount = 0
sixtyToNinetyAmount = txtAmount.Text
moreThanNinetyAmount = 0
ElseIf dtpDate.Value > dateNinety Then
oneToThirtyAmount = 0
thirtyToSixtyAmount = 0
sixtyToNinetyAmount = 0
moreThanNinetyAmount = txtAmount.Text
End If
Re: [2005] Comparing Dates
but, i just noticed
vb Code:
Dim tempDate As DateTime = dtpDate.Value
if dateThirty = dtpDate.Value + 30 days & dateSixty = dtpDate.Value + 60 then your if statements are incorrect. dtpDate.Value is never going to be anything but tempDate
1 Attachment(s)
Re: [2005] Comparing Dates
what ive done is this..
Code:
Dim tempDate As DateTime = dtpDate.Value
Dim dateThirty As Date = tempDate.AddDays(30)
Dim dateSixty As Date = tempDate.AddDays(60)
Dim dateNinety As Date = tempDate.AddDays(90)
Dim oneToThirtyAmount As New Integer
Dim thirtyToSixtyAmount As New Integer
Dim sixtyToNinetyAmount As New Integer
Dim moreThanNinetyAmount As New Integer
If tempDate <= dateThirty Then
oneToThirtyAmount = txtAmount.Text
thirtyToSixtyAmount = 0
sixtyToNinetyAmount = 0
moreThanNinetyAmount = 0
ElseIf tempDate > dateThirty And tempDate <= dateSixty Then
oneToThirtyAmount = 0
thirtyToSixtyAmount = txtAmount.Text
sixtyToNinetyAmount = 0
moreThanNinetyAmount = 0
ElseIf tempDate > dateSixty And tempDate <= dateNinety Then
oneToThirtyAmount = 0
thirtyToSixtyAmount = 0
sixtyToNinetyAmount = txtAmount.Text
moreThanNinetyAmount = 0
ElseIf tempDate > dateNinety Then
oneToThirtyAmount = 0
thirtyToSixtyAmount = 0
sixtyToNinetyAmount = 0
moreThanNinetyAmount = txtAmount.Text
End If
it seems the same to your code.. here is the ouput..
seems like there's something wrong with the code..(but there's a little improvement lol xD)
Re: [2005] Comparing Dates
Dim tempDate As DateTime = dtpDate.Value
Dim dateThirty As Date = tempDate.AddDays(30)
tempDate is never going to be greater than dateThirty because dateThirty = tempDate.AddDays(30)
Re: [2005] Comparing Dates
yeah right!! i got your point!! tnx to that..(currently thinking what to replace)
*swt* silly me.. hmmm.. what must be.. uhmm, errrr, a little help sir :D
Re: [2005] Comparing Dates
if you want to know if 'now' is between tempDate + dateThirty
vb Code:
If now >= tempDate and now <= dateThirty Then
Re: [2005] Comparing Dates
Quote:
Originally Posted by .paul.
if you want to know if 'now' is between tempDate + dateThirty
vb Code:
If now >= tempDate and now <= dateThirty Then
you know what? THANK YOU!! i mean THANK YOU THANK YOU!!! that solves my problem!!! tnx again!!(rated you lol :D)
1 Attachment(s)
Re: [2005] Comparing Dates
Here's the updated code.
Code:
txtPayee.Visible = False
txtAmount.Visible = False
dtpDate.Visible = False
objDataAdapter.SelectCommand = New SqlCommand()
objDataAdapter.SelectCommand.Connection = objConnection
objDataAdapter.SelectCommand.CommandText = _
"SELECT MGL_Payee, MGL_TotalAmount, MGL_ReferenceDate FROM tbl_MGLTransaction"
objDataAdapter.SelectCommand.CommandType = CommandType.Text
Dim objDataSet As New DataSet()
objConnection.Open()
objDataAdapter.Fill(objDataSet, "tbl_MGLTransaction")
objDataView = New DataView(objDataSet.Tables("tbl_MGLTransaction"))
'Clear then Bind
txtPayee.DataBindings.Clear()
txtAmount.DataBindings.Clear()
dtpDate.DataBindings.Clear()
txtPayee.DataBindings.Add("Text", objDataView, "MGL_Payee")
txtAmount.DataBindings.Add("Text", objDataView, "MGL_TotalAmount")
dtpDate.DataBindings.Add("Value", objDataView, "MGL_ReferenceDate")
objConnection.Close()
Dim tempDate As DateTime = dtpDate.Value
Dim dateThirty As Date = tempDate.AddDays(30)
Dim dateSixty As Date = tempDate.AddDays(60)
Dim dateNinety As Date = tempDate.AddDays(90)
Dim oneToThirtyAmount As New Integer
Dim thirtyToSixtyAmount As New Integer
Dim sixtyToNinetyAmount As New Integer
Dim moreThanNinetyAmount As New Integer
If Now >= tempDate And Now <= dateThirty Then
oneToThirtyAmount = txtAmount.Text
thirtyToSixtyAmount = 0
sixtyToNinetyAmount = 0
moreThanNinetyAmount = 0
ElseIf Now > dateThirty And Now <= dateSixty Then
oneToThirtyAmount = 0
thirtyToSixtyAmount = txtAmount.Text
sixtyToNinetyAmount = 0
moreThanNinetyAmount = 0
ElseIf Now > dateSixty And Now <= dateNinety Then
oneToThirtyAmount = 0
thirtyToSixtyAmount = 0
sixtyToNinetyAmount = txtAmount.Text
moreThanNinetyAmount = 0
ElseIf Now > dateNinety Then
oneToThirtyAmount = 0
thirtyToSixtyAmount = 0
sixtyToNinetyAmount = 0
moreThanNinetyAmount = txtAmount.Text
End If
'Bind
'Insert To Table
'Retrieve To Table
'Bind To DataGrid
'Delete Record From Table
Dim objConnection2 As SqlConnection = New _
SqlConnection("Data Source=MORETHANENOUGH\SQLEXPRESS;Initial Catalog=accountingdb;Integrated Security=True")
Dim objCommand2 As SqlCommand = New SqlCommand()
objCommand2.Connection = objConnection2
objCommand2.CommandText = "INSERT INTO tbl_ARAging " & _
"(Payee, TotalAmount, ReferDate, OneToThirty, ThirtyToSixty, SixtyToNinety, MoreThanNinety) " & _
"VALUES(@Payee, @TotalAmount, @ReferDate, @OneToThirty, @ThirtyToSixty, @SixtyToNinety, @MoreThanNinety)"
objCommand2.Parameters.AddWithValue("@Payee", txtPayee.Text)
objCommand2.Parameters.AddWithValue("@TotalAmount", txtAmount.Text)
objCommand2.Parameters.AddWithValue("@ReferDate", dtpDate.Value)
objCommand2.Parameters.AddWithValue("@OneToThirty", oneToThirtyAmount.ToString)
objCommand2.Parameters.AddWithValue("@ThirtyToSixty", thirtyToSixtyAmount.ToString)
objCommand2.Parameters.AddWithValue("@SixtyToNinety", sixtyToNinetyAmount.ToString)
objCommand2.Parameters.AddWithValue("@MoreThanNinety", moreThanNinetyAmount.ToString)
objConnection2.Open()
objCommand2.ExecuteNonQuery()
objConnection2.Close()
Dim objConnection3 As New SqlConnection _
("Data Source=MORETHANENOUGH\SQLEXPRESS;Initial Catalog=accountingdb;Integrated Security=True")
objDataAdapter3.SelectCommand = New SqlCommand()
objDataAdapter3.SelectCommand.Connection = objConnection3
objDataAdapter3.SelectCommand.CommandText = ("select Payee, TotalAmount, ReferDate, OneToThirty, ThirtyToSixty, SixtyToNinety, MoreThanNinety FROM tbl_ARAging")
objDataAdapter3.SelectCommand.CommandType = CommandType.Text
Dim objDataSet3 As New DataSet()
objConnection3.Open()
objDataAdapter3.Fill(objDataSet3, "tbl_ARAging")
objDataView3 = New DataView(objDataSet3.Tables("tbl_ARAging"))
grdAuthorTitles.DataSource = objDataSet3
grdAuthorTitles.DataMember = "tbl_ARAging"
grdAuthorTitles.Columns(0).HeaderText = "Payee"
grdAuthorTitles.Columns(1).HeaderText = "TotalAmount"
grdAuthorTitles.Columns(2).HeaderText = "Reference Date"
grdAuthorTitles.Columns(3).HeaderText = "1 - 30"
grdAuthorTitles.Columns(4).HeaderText = "31 - 60"
grdAuthorTitles.Columns(5).HeaderText = "61 - 90"
grdAuthorTitles.Columns(6).HeaderText = ">90"
objConnection3.Close()
Dim objConnection4 As New SqlConnection _
("Data Source=MORETHANENOUGH\SQLEXPRESS;Initial Catalog=accountingdb;Integrated Security=True")
Dim objCommand4 As SqlCommand = New SqlCommand()
objCommand4.Connection = objConnection4
objCommand4.CommandText = ("DELETE FROM tbl_ARAging")
objConnection4.Open()
objCommand4.ExecuteNonQuery()
objConnection4.Close()
last problem..
before, this are my records in tbl_MGLTransaction (Figure 1)
now, ive added a new record.. (figure 2)
when i run code, the output is the same as before.. (figure 3)
how can i make it to look like figure 4 ?
it didnt add my 2nd record to datagridview..
Re: [2005] Comparing Dates
i'm not sure what you're asking.
i'm not an expert with databases. you could try the database development forum. ask a moderator to move this thread
Re: [2005] Comparing Dates
ooohhh.. i seee.. btw, tnx again... you've been a big help to me :D hope a moderator would see this..
Re: [2005] Comparing Dates
updated 1st post.. someone pls.. need help.. pls see my 3rd and 4th question.. tnx..