Birthday date problems
-
Microsoft Access doesnt seem to support "LIKE", and by the way, the date in my database is saved in this format (yyyy/mm/dd). Im getting errors running this.It doesnt seem to understand LIKE. Thanx again.
kagiso
matjame wrote:
Microsoft Access doesnt seem to support "LIKE", and by the way, the date in my database is saved in this format (yyyy/mm/dd). Im getting errors running this.It doesnt seem to understand LIKE.
Hi, I have checked in MsAccess itself. its working fine. as yr format is (yyyy/mm/dd). Then you have to change the query.
SELECT * FROM testbl where myDate like '*/9/12'
Thanks, Sun Rays
-
matjame wrote:
Microsoft Access doesnt seem to support "LIKE", and by the way, the date in my database is saved in this format (yyyy/mm/dd). Im getting errors running this.It doesnt seem to understand LIKE.
Hi, I have checked in MsAccess itself. its working fine. as yr format is (yyyy/mm/dd). Then you have to change the query.
SELECT * FROM testbl where myDate like '*/9/12'
Thanks, Sun Rays
Syntax error (missing operator) in query expression 'BirthDate LIKE '*/09/20' 2007/11/13'. comx = New OleDbCommand("Select * from Bithdays where BirthDate LIKE '*/09/20' " & Date.Today, conx) comx.Connection = conx 'enure that the command follows the rite connection If conx.State = ConnectionState.Open Then conx.Close() End If conx.Open() Dim datar As OleDbDataReader = comx.ExecuteReader Error appears on the above statement
kagiso
-
Syntax error (missing operator) in query expression 'BirthDate LIKE '*/09/20' 2007/11/13'. comx = New OleDbCommand("Select * from Bithdays where BirthDate LIKE '*/09/20' " & Date.Today, conx) comx.Connection = conx 'enure that the command follows the rite connection If conx.State = ConnectionState.Open Then conx.Close() End If conx.Open() Dim datar As OleDbDataReader = comx.ExecuteReader Error appears on the above statement
kagiso
matjame wrote:
Syntax error (missing operator) in query expression 'BirthDate LIKE '*/09/20' 2007/11/13'. comx = New OleDbCommand("Select * from Bithdays where BirthDate LIKE '*/09/20' " & Date.Today, conx) comx.Connection = conx 'enure that the command follows the rite connection If conx.State = ConnectionState.Open Then conx.Close() End If conx.Open() Dim datar As OleDbDataReader = comx.ExecuteReader Error appears on the above statement
Hi, What are you doing here ???????? write query as below...
Select * from Bithdays where BirthDate LIKE '*/" + DateTime.Now.Day.ToString() + "/" + DateTime.Now.Month.ToString() "'"
Thanks, Sun Rays
-
matjame wrote:
Syntax error (missing operator) in query expression 'BirthDate LIKE '*/09/20' 2007/11/13'. comx = New OleDbCommand("Select * from Bithdays where BirthDate LIKE '*/09/20' " & Date.Today, conx) comx.Connection = conx 'enure that the command follows the rite connection If conx.State = ConnectionState.Open Then conx.Close() End If conx.Open() Dim datar As OleDbDataReader = comx.ExecuteReader Error appears on the above statement
Hi, What are you doing here ???????? write query as below...
Select * from Bithdays where BirthDate LIKE '*/" + DateTime.Now.Day.ToString() + "/" + DateTime.Now.Month.ToString() "'"
Thanks, Sun Rays
Syntax error in string in query expression 'BirthDate LIKE '*/13/11'. error points here GridView1.DataSource = cm.ExecuteReader(CommandBehavior.CloseConnection) Dim con As New OleDbConnection Dim str1 As String = "Provider = Microsoft.Jet.oledb.4.0; Data source =C:\Documents and Settings\kagisho.mashiloane\My Documents\Visual Studio 2005\Projects\Search AL\TelephoneList.mdb" Dim cm As OleDbCommand Dim str2 As String con = New OleDbConnection(str1) con.Open() str2 = "Select * from Bithdays where BirthDate LIKE '*/" & DateTime.Now.Day.ToString() & "/" & DateTime.Now.Month.ToString() cm = New OleDbCommand(str2, con) GridView1.DataSource = cm.ExecuteReader(CommandBehavior.CloseConnection) GridView1.DataBind()
kagiso
-
Hello guys. I have a date\time field from my Access database (ie 1983/09/20) and I need to extract that and check if its today.If the month and day correspond with today then I wana print all those people's details and a happy birthday message. I knw this is a crap code but Im clueless on this one Dim comx As New OleDbCommand Dim conx As New OleDbConnection conx = New OleDbConnection("Provider = Microsoft.Jet.oledb.4.0; data source = C:\Documents and Settings\kagisho.mashiloane\My Documents\Visual Studio 2005\Projects\Search AL\TelephoneList.mdb") conx.Open() 'Tell the command which values to pull/get comx = New OleDbCommand("Select * from Bithdays where BirthDate = " & Today.Date, conx) comx.Connection = conx 'enure that the com Please help guys.Thanx in advance.I jus wana compare the day and month to today.
kagiso
hi try with this query.. if i m not wrong then BirthDate is your table column name .. select * from Tablename WHERE (DATEPART(month, BirthDate) = @mt) AND (DATEPART(day, BirthDate) = @dt) set value of this both variable as u want
Jintal Patel
-
hi try with this query.. if i m not wrong then BirthDate is your table column name .. select * from Tablename WHERE (DATEPART(month, BirthDate) = @mt) AND (DATEPART(day, BirthDate) = @dt) set value of this both variable as u want
Jintal Patel
Ok, I tried and loved it but the problem is that the values I have to give it are system generated(i.e the day and month I get from the database are compared to the day and month from my machine) so I cant use that method. But I tried to do this str2 = "Select * from Bithdays where WHERE (DATEPART(month, BirthDate)) = " & Date.Today.Day & AND "(DATEPART(day, BirthDate) = " & date.Today.Month But Im getting an error on "AND"
kagiso
-
Ok, I tried and loved it but the problem is that the values I have to give it are system generated(i.e the day and month I get from the database are compared to the day and month from my machine) so I cant use that method. But I tried to do this str2 = "Select * from Bithdays where WHERE (DATEPART(month, BirthDate)) = " & Date.Today.Day & AND "(DATEPART(day, BirthDate) = " & date.Today.Month But Im getting an error on "AND"
kagiso
your syntax is wrong near '" & Date.Today.Day ' for concat so correct syntax
Jintal Patel
-
your syntax is wrong near '" & Date.Today.Day ' for concat so correct syntax
Jintal Patel
-
your syntax is wrong near '" & Date.Today.Day ' for concat so correct syntax
Jintal Patel
-
Ok, I tried and loved it but the problem is that the values I have to give it are system generated(i.e the day and month I get from the database are compared to the day and month from my machine) so I cant use that method. But I tried to do this str2 = "Select * from Bithdays where WHERE (DATEPART(month, BirthDate)) = " & Date.Today.Day & AND "(DATEPART(day, BirthDate) = " & date.Today.Month But Im getting an error on "AND"
kagiso
matjame wrote:
the problem is that the values I have to give it are system generated(i.e the day and month I get from the database are compared to the day and month from my machine) so I cant use that method.
Yes, you can. The @mt and @dt values are parameters. Add two parameter objects to the command object, with the values for the month and day.
Experience is the sum of all the mistakes you have done.
-
Conversion from string "Select * from Bithdays WHERE (DA" to type 'Long' is not valid. Error appears here str2 = "Select * from Bithdays WHERE (DATEPART(month, BirthDate)) = " & Date.Today.Day And "(DATEPART(day, BirthDate) = " & Date.Today.Month
kagiso
hii sorry for let reply.. try this... str2 = " Select * from Bithdays WHERE (DATEPART(month, BirthDate)) ='" & Date.Today.Day &"' And (DATEPART(day, BirthDate) = '" & Date.Today.Month & "'"
Jintal Patel
-
hii sorry for let reply.. try this... str2 = " Select * from Bithdays WHERE (DATEPART(month, BirthDate)) ='" & Date.Today.Day &"' And (DATEPART(day, BirthDate) = '" & Date.Today.Month & "'"
Jintal Patel
Your solution has been morethan helpful.Now I can see the light, but the little problem I now encounter is that "No value given for one or more required parameters.".It was showing month as 14 which is today's day and 11 as the day which is the month.But after sorting the missing ")". I get this message on the GridView1.DataSource = cm.ExecuteReader(CommandBehavior.CloseConnection) GridView1.DataBind(). I checked the values how they correspond with the string, its fine and the date formate(yyyy/mm/dd) is fine.What cud be the problem now.
kagiso
-
Your solution has been morethan helpful.Now I can see the light, but the little problem I now encounter is that "No value given for one or more required parameters.".It was showing month as 14 which is today's day and 11 as the day which is the month.But after sorting the missing ")". I get this message on the GridView1.DataSource = cm.ExecuteReader(CommandBehavior.CloseConnection) GridView1.DataBind(). I checked the values how they correspond with the string, its fine and the date formate(yyyy/mm/dd) is fine.What cud be the problem now.
kagiso
please send me the total code or that function so i can understand your problem perfactly...
Jintal Patel
-
please send me the total code or that function so i can understand your problem perfactly...
Jintal Patel
Imports System.Data Imports System.Web.UI.Control Imports System.Web.UI.WebControls.WebControl Imports System.Web.UI.WebControls.LinkButton Imports System.Data.oledb Imports Microsoft.VisualBasic.ApplicationServices Imports Microsoft.VisualBasic.OpenShare Partial Class Birthdays Inherits System.Web.UI.Page Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Dim comx As New OleDbCommand Dim conx As New OleDbConnection Dim con As New OleDbConnection Dim str1 As String = "Provider = Microsoft.Jet.oledb.4.0; Data source =C:\Documents and Settings\kagisho.mashiloane\My Documents\Visual Studio 2005\Projects\Search AL\TelephoneList.mdb" Dim cm As OleDbCommand Dim str2 As String con = New OleDbConnection(str1) con.Open() str2 = " Select * from Bithdays WHERE (DATEPART(Month, BirthDate)) ='" & Date.Today.Month & "' And (DATEPART(Day, BirthDate)) = '" & Date.Today.Day & "'" cm = New OleDbCommand(str2, con) GridView1.DataSource = cm.ExecuteReader(CommandBehavior.CloseConnection) GridView1.DataBind() If con.State = ConnectionState.Open Then con.Close() End If con.Open() End Sub Again, thank you very much for ur time and effort
kagiso
-
Imports System.Data Imports System.Web.UI.Control Imports System.Web.UI.WebControls.WebControl Imports System.Web.UI.WebControls.LinkButton Imports System.Data.oledb Imports Microsoft.VisualBasic.ApplicationServices Imports Microsoft.VisualBasic.OpenShare Partial Class Birthdays Inherits System.Web.UI.Page Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Dim comx As New OleDbCommand Dim conx As New OleDbConnection Dim con As New OleDbConnection Dim str1 As String = "Provider = Microsoft.Jet.oledb.4.0; Data source =C:\Documents and Settings\kagisho.mashiloane\My Documents\Visual Studio 2005\Projects\Search AL\TelephoneList.mdb" Dim cm As OleDbCommand Dim str2 As String con = New OleDbConnection(str1) con.Open() str2 = " Select * from Bithdays WHERE (DATEPART(Month, BirthDate)) ='" & Date.Today.Month & "' And (DATEPART(Day, BirthDate)) = '" & Date.Today.Day & "'" cm = New OleDbCommand(str2, con) GridView1.DataSource = cm.ExecuteReader(CommandBehavior.CloseConnection) GridView1.DataBind() If con.State = ConnectionState.Open Then con.Close() End If con.Open() End Sub Again, thank you very much for ur time and effort
kagiso
hiii this will definately work just change ur str2 to belove str2 = "select * from Birthday WHERE (DATEPART('m', BDate)) = '" & Date.Today.Month & "' And (DATEPART('d', BDate)) = '" & Date.Today.Day & "'" cm = New OleDbCommand(str2, con) GridView1.DataSource = cm.ExecuteReader(CommandBehavior.CloseConnection) GridView1.DataBind()
Jintal Patel
-
hiii this will definately work just change ur str2 to belove str2 = "select * from Birthday WHERE (DATEPART('m', BDate)) = '" & Date.Today.Month & "' And (DATEPART('d', BDate)) = '" & Date.Today.Day & "'" cm = New OleDbCommand(str2, con) GridView1.DataSource = cm.ExecuteReader(CommandBehavior.CloseConnection) GridView1.DataBind()
Jintal Patel
-
matjame wrote:
Syntax error (missing operator) in query expression 'BirthDate LIKE '*/09/20' 2007/11/13'. comx = New OleDbCommand("Select * from Bithdays where BirthDate LIKE '*/09/20' " & Date.Today, conx) comx.Connection = conx 'enure that the command follows the rite connection If conx.State = ConnectionState.Open Then conx.Close() End If conx.Open() Dim datar As OleDbDataReader = comx.ExecuteReader Error appears on the above statement
Hi, What are you doing here ???????? write query as below...
Select * from Bithdays where BirthDate LIKE '*/" + DateTime.Now.Day.ToString() + "/" + DateTime.Now.Month.ToString() "'"
Thanks, Sun Rays
Howzit Sun Rays. Here is how the problem was solved. str2 = "select * from Bithdays WHERE (DATEPART('m', BDate)) = '" & Date.Today.Month & "' And (DATEPART('d', BDate)) = '" & Date.Today.Day & "'" cm = New OleDbCommand(str2, con) GridView1.DataSource = cm.ExecuteReader(CommandBehavior.CloseConnection) GridView1.DataBind() Thanx a million for your assistance
kagiso
-
You have no idea how much this means to me.It works like a charm. I wud buy you lunch, but ur there.Thanx a million. Damn, thank you very much.
kagiso
welcome
Jintal Patel