from date to date

I am working on a form for livestock. one of the things in the form is a checkbox to let me know if they qualify or not. the second is I have a created record field entered into the database... now my question is I am doing a search on this and cant figure it out since i am new to all this...i have a query that selects the qualification checkbox (where qualify = 'true') then another query that selects the created record date... and the search is that I want to get the information in the livestock that are qualifyed (have the checkbox qualify = to 'true') between  one date and another that I enter... can someone help

0
lithcause
8/11/2008 2:14:20 PM
asp.net.web-forms 93655 articles. 6 followers. Follow

9 Replies
1654 Views

Similar Articles

[PageSpeed] 28

Hi lithcause 

I could do with a bit more information such as the design of your table in the database, and if you are using stored procedures etc. However, I have included some code below on the offchance that it will serve your requirements (and on the presumption that I undestand what you are asking!). Hope it helps. 

        Dim sqlCommand1 As New System.Data.SqlClient.SqlCommand("select * from [livestock] where entry_date='" & entryDate.ToShortDateString & "' and is_qualified=" & IIf(qualified, 1, 0))
        Dim sqlConnection As System.Data.SqlClient.SqlConnection = New System.Data.SqlClient.SqlConnection("Data Source=localhost;Initial Catalog=LivestockDB; Integrated Security=True")
        Try
            With sqlConnection
                .Open()
                Dim tmpDR As Data.SqlClient.SqlDataReader = sqlCommand1.ExecuteReader(System.Data.CommandBehavior.CloseConnection)
                'do whatever work you want using the datareader here.
                tmpDR.Close()
            End With
        Catch ex As Exception
            Throw ex
        End Try
 

 

HTH,

Mausy


If this post answers your question please "mark it as answer" on the title of the post in order to inform other users! Thanks. Mausy
0
mausy
8/11/2008 2:43:13 PM

Hi!

I'm assuming you're looking for an SQL query. You run the following query:
SELECT * FROM Livestock WHERE qualify='true' AND created_date BETWEEN @start_date AND @end_date;

You might want to try using IronSpeed Designer. There's a free version that can do this for you automatically.

Regards,
Nitin

0
k_nitin_r
8/11/2008 2:47:53 PM

then I receive this error

Conversion failed when converting the nvarchar value '01/21/2006' to data type int.

0
lithcause
8/11/2008 3:03:53 PM

now i receive this error

Conversion failed when converting the nvarchar value '01/21/2006' to data type int.

0
lithcause
8/11/2008 3:05:04 PM

Can you please give us an idea of your relevant database design i.e. the data type of columns used in the table and whether you are using stored procedures etc.

Thanks,

Mausy


If this post answers your question please "mark it as answer" on the title of the post in order to inform other users! Thanks. Mausy
0
mausy
8/11/2008 3:28:12 PM

using sql 2005, no stored procedures. just simple c.r.u.d. form. The create record data in in date format dd/mm/yyyy. I have the data set into 3 tables contacts, farmInfo, and LabInfo. the record created is in the contacts table and the qualify checkbox is in the farmInfo table as a bit. I have the tables joined by "Cid". the datefield is set up ar an nvarchar. type of columns? dont know what you mean ? like i said I am new to this.. I will try to find out as much info as you need... thanks for your help 

0
lithcause
8/11/2008 3:46:11 PM
My understanding is still a little sketchy but from what you have said does the following fit your needs...

1. Is it possible for you to change the type of the date column to be of type datetime?
2. Use a similar method as i mentioned in my first post but with the following SQL string instead:

"select * from contacts c inner join farmInfo f on f.cid=c.cid and c.entry_date between '" & StartDate & "' and '" & EndDate
HTH,
Mausy

If this post answers your question please "mark it as answer" on the title of the post in order to inform other users! Thanks. Mausy
0
mausy
8/11/2008 4:03:18 PM

everytime i use the dateformat (now() dd/mm/yyyy) it gives an error if sql column is a date field that is why i have it as a nvarchar

0
lithcause
8/11/2008 5:35:57 PM

ok now I found my problem thanks for your help it turned out to be a siple mistake with ' and (

where (qualify = 'true') And (ContactInfo.RecordCreated BETWEEN '#form.StartDate#' AND '#form.EndDate#')

0
lithcause
8/11/2008 6:15:46 PM
Reply:

Similar Artilces:

Dates, Dates, Dates!
Hello all... I am in the process of building an appointment system, and I am trying to see if I can get some pointers on which way to go on this. The first version of this appointment system was very lo-tech, and it stored all of the possible dates/times in the database. Once a user booked an appointment, their information was logged to that date/time, and then that date/time would no longer show in the list of possible openings. This was great for a temporary fix, but with having to pre-populate all of the dates/times, the system would eventually have to be updated to continue on pa...

How to convert a chinese date to english date in web form?
Hi ASP.NET Proz,  I try to convert a chinese charater date (18-一月-2008) to english date (18-Jan-2008) from a web form. Is that possible?  Thanks in advance for the Proz!  * .NET Proz always make impossible to possible Try this one:   System.Globalization.CultureInfo nlCulture = new System.Globalization.CultureInfo("zh-CHT"); // Chinese Traditional DateTime date = DateTime.MinValue; DateTime.TryParseExact(chineseDateString, "dd-MMM-yyyy", nlCulture, System.Globalization.DateTimeStyles.None, out date); ...

From Date and To Date
 In my application i have two textboxes.One for From date and the other one for To date.I need to check whether the From date is lesser than To Date..Date formats will be either(DD-MM-YYYY) or (DD/MM/YYYY).and i have used calendar extender for selecting dateI need the script code to do this...Thanks in advance See this thread: http://forums.asp.net/t/1346328.aspxMohsin Naeem"Please mark as answer if it helped you"  <form id="form1" runat="server"> <asp:ScriptManager ID="ScriptManager1" runat="server"> </...

convert date christian date to persian date
hi, I need to convert christain date that was produced in my Sql database to persian date like" دوشنبه 21 مرداد 1378" in a datalist.Could you recommend me any function.I use VisualStudio 2005 & VB. thanks in advance Sepid Take a read of http://www.codeproject.com/KB/database/PersianDateInSQLServer.aspx or maybe a javascript route like http://www.codeproject.com/KB/gadgets/PersianDateViewerGadge.aspx Hope it helpsRegardsJeremyIf this has helped Please: Don't forget to click "Mark as Answer" on the post that helped you.That way future readers will ...

No date in Date field
I have just installed thunderbird on my system. I migrated from outlook express. All the mail that was there before shows both the date and the time in the date field. However, all mail received by thunderbird only has a time stamp, no date. How do I correct this?? Thanks, Roger _Roger Bailey_ spoke thusly on 29/08/2006 10:09 PM: > I have just installed thunderbird on my system. I migrated from outlook > express. All the mail that was there before shows both the date and the > time in the date field. However, all mail received by thunderbird only has ...

the From date should be lesser than To Date
 In my application i have two textboxes.One for From date and the other one for To date.I need to check whether the From date is lesser than To Date..Date formats will be either(DD-MM-YYYY) or (DD/MM/YYYY).and i have used calendar extender for selecting dateI need the script code to do this...Thanks in advance DateTime.Compare(t1,t2); Value Type Condition Less than zero  t1 is earlier than t2. Zero t1 is the same as t2. Greater than zero t1 is later than t2. "Object reference not set to an instance of an object" from date :(i...

compare date to a date
I have in a where clause the following statement. SELECT "sales"."sale_date", "sales"."ling_no", "sales"."course_no", "sales"."product_no", "sales"."service_no", "sales"."quantity", "sales"."amount", "payment"."amount", "payment"."payment_form" FROM "payment", "sales" WHERE ( "sales".&...

dates between date ranges
hi, i need 1 help regarding query, i have Startdate and Enddate using SELECT statement i need all the dates between these 2 dates, is it possible or i had to do it programatically, or i had insert data only please helpThanksParthvisit for some interesting articals at www.parthrawal.blogspot.comMark as Answer if it helps you  declare @temp table ( [date] datetime ) declare @startdate datetime,@enddate datetime set @startdate = getdate() -- here you can write a select stmt as "select startdate from tablename" set @enddate = getdate() + 10 -- here you can write a ...

calendar date span (date start : date end)
Hi! Can anyone help me with this? Say, I have these two textboxes. Date Start:        Date End:             What I wanted to do is to put dates on it using the calendar. My problem is I do not know what to do to keep the "Date Start" not way after the set "Date End", and for "Date End" not way before the set "Date Start".   example: Date Start: July 1, 2008              &nb...

Date() == new Date()
Ecma wise, what's the expected return from the above, true or false? I know 'Date()' called as a function returns a string, while 'new Date()' returns an object. I also know Date.toString() is getting called (SM) for 'new Date()' before the '==' equality operator is evaluated (to 'true'). What's the expected return for Date() === new Date()? Thanks for the attention! Celso Celso Aguiar wrote: > Ecma wise, what's the expected return from the above, true or false? > I know 'Date()' called as a function returns a string...

search date TO date
Hii all...haii..im still beginner in asp.net..here i want to know how to create search date until date?here is my example:- Hi, I don't see your code------------------------if an answer, mark it so. Hi yanz_shi, As mentioned, we couldn't see your example. Please check the thread after you've created it so that we can help you better. Also, for searching between two dates, you could do it like this: select * from tab where dt between date1 and date2 Thanks.David QianMicrosoft Online Community SupportPlease remember to mark the replies as answers if they help and unmark ...

How to convert Julian date into Calendar date (VB.Net)
Hi all, I have some dates which are in Julian format and I need to convert them into calendar dates  for example if the Julian date is 1, I need to be able to convert it into 1/1/2007, If the julian date is 66 then I would need to convert it to 3/7/2007 and so on. Every year would start with 1 and end with 365365 = 12/31/2007. Is there a vb.net function or tutorial somewhere ? thanks for any help.    1) Your dates aren't in Julian format!! 2) How do you know which year you are referring to? 3) Have you tried the AddDays function of the Date/DateTim...

date field = date
i made an news table and i made and option to add and update and delete news from it i need one thing that when someone try to add news the time that he insert the news will be in teh date field of the table and dont the costumer write it   hope that u understand me Hi, did you mean you want to add a column that get current date as its value automaticly? If so, you can do the following in Access2003: 1. add a column with 'Date/Time' data time 2. In the 'Field Properties'->'General' pannel, add a 'Default Value' for it, 3. In the 'Expression Builder', double cli...

Filter for null dates, dates less than other specific date
Hi, I want to get those rows from a datawindow which has date value as null or the date value is less than some other specific date. I need to do this after the data is retrieved using filter. Its equivalent in SQL would be like my_date < TO_DATE('11/20/2007','MM/DD/YYYY') OR my_date IS NULL Please let me know how this can be achieved to filter data in datawindow. DaysAfter() and IsNull() are your friends. <prabhakar.narvekar@gmail.com> wrote in message news:8be40319-722a-4dca-bba2-9e076a41ac5f@s19g2000prg.googlegroups.com... > Hi, > I ...

Web resources about - from date to date - asp.net.web-forms

A Bad Lip Reading of Star Wars
The Star Wars “week of frenzy” would not be complete without every video series trying their hand at the original trilogy. That includes the ...

How US rate hike affects Australia
THE most telegraphed US rate rise in history is expected to provoke bigger moves on financial markets than what’s been seen so far.

Pentagon chief Carter used personal email account at times, has stopped: statement
Reuters Pentagon chief Carter used personal email account at times, has stopped: statement Reuters WASHINGTON U.S. Defense Secretary Ash Carter ...

Top Google searches in 2015 show Aussies are really curious about Netflix
It was a year of real highs and lows for Aussies, if their 2015 Google searches are anything to go by. Netflix finally arrived Down Under, making ...

Mistrial underscores prosecutors' tough task in Baltimore police cases
NBCNews.com Mistrial underscores prosecutors' tough task in Baltimore police cases Reuters NEW YORK A mistrial on Wednesday in the case of ...

Google says proposed DMV rules requiring steering wheel, pedals, and licensed drivers with special certification ...
Gabe Nelson / Automotive News Automaker : Google says proposed DMV rules requiring steering wheel, pedals, and licensed drivers with special ...

Skype for Business launches on Android
Skype for Business has launched on Android following months in the company’s preview program. Skype has designed the app to maximize productivity ...

UN Set to Adopt Resolution to Disrupt Islamic State Funds
UN Security Council set to adopt resolution aimed at disrupting Islamic State group's funding

Microsoft aims to supply Chinese government with customized Windows 10
After signing a deal with China's answer to Google in September, Microsoft is again strengthening its position in the country, this time by providing ...

Moviegoers Still Feel Safe After Recent Terror Attacks: New Study
Terrorist attacks in Paris and San Bernardino, Calif., have become hot topics in the presidential race and dominated the media. Despite wide-spread ...

Resources last updated: 12/17/2015 8:27:58 AM