Problem In Searching Records By Date In Sql Query For Asp.net

Oct 8, 2007

In my asp.net web application I used two textboxes for date1 and date2 to search records


I have used two variable in my stored procedure

@OrderDate1 datetime,
@OrderDate2 datetime,

for todays record (values for date1 and Date2)
set @OrderDate1='09/20/2007 12:00 AM';
set @OrderDate2='09/20/2007 11:59 PM';

for records between (values for date1 and Date2)
set @OrderDate1='09/20/2007 12:00 AM';
set @OrderDate2='09/24/2007 11:59 PM';

I have to search the todays records OR records between these two days
(OrderDate >= @OrderDate1 ) AND (OrderDate <= @OrderDate2)

It
works fine in my local server>>It finds the todays records by
ginving same date (@OrderDate1 and @OrderDate2) and records between two
dates

but it does not work for sql server which is outside india ...if it is problem of date format how i can solve that..

Thanks

View 1 Replies


ADVERTISEMENT

Reporting Services :: Searching By Single Date Or Date Range

Apr 22, 2015

I would like to be able to search by a single date, @StartDate, or by a date range , between @StartDate and @EndDate. I am having a hard time with the logic on this for a report in SSRS.

View 5 Replies View Related

Searching Records?

Jul 20, 2004

I want to create a stored procedure which takes a project name and returns any project with a name similar or = to the input parameter. This is so the user can search for a project although the spelling may be incorrect or whatever.....

Any hints on how to start this? It seems that I could use SOUNDEX or DIFFERENCE, but I don't know where to start.

Any hints?

Mike B

View 7 Replies View Related

Transact SQL :: How To Query Records For A Date Range

Oct 14, 2015

This one is making my head hurt!  Trying to figure out how to query for records between date range.  The records have a start_date and an end_date field.  The end_date field maybe null.

For example, say you wanted to see the records of everyone checked into a hotel during a given date range.  You need to account for the people that checked in before you @start_date parameter and may check out after your @end_date parameter.  

fyi- As for the null end_date field, think of this as they have checked in and not sure when they will checkout yet.

View 7 Replies View Related

Error In Searching Records

Jan 29, 2006

Hi I am developing windows application. I want to find records which has a particular number which is entered in textbox. and result is displayed in datagrid. If the entered number didnt find in database it must be displayed msg. i tried it like as below but not working. qlConnection conn = new SqlConnection();             conn.ConnectionString = "Server=EBSERVER;UID=sa;Database=Airport-Clearance;";             //SqlConnection sqlconn = objcs.GetConnection();             //MessageBox.Show("Connected");             //sqlconn.Open();             //Do what ever                          SqlDataAdapter filling = new SqlDataAdapter("select * from Airport where awb='" + txtawb.Text ,conn);                          DataSet displaying = new DataSet();                          conn.Open();             filling.Fill(displaying);             dataGrid1.DataSource = displaying.DefaultViewManager;             conn.Close(); Waiting for reply. Warmest regards, ASIF

View 1 Replies View Related

Searching For Records With Null Values

Oct 9, 2007

I'm hoping someone can help me with my problem.
I'm reading in records from a 'flat file' and loading them into sql.
I have 5 values I'm loading in.  I first check my sql db, if all 5 values match a current record in sql, I don't want to load the record, because it's already there.  If it doesn't exist, I need to load it.
It works fine as long as none of my values are NULL.  But if I have a record with a field, say Gender, that is null, if its a new record it loads fine, setting gender to NULL in sql.  But then when I encounter another record, which is identical, I'm testing to see if it already exists by  doing a 'select where Gender = @Gender'   and it always returns that the record does not exist in the db - even though it exists (because its using the = instead of is null)! 
I need some mechanism where if the value is null it tests 'Gender is null'  but if there is a value, it tests gender=gender, [and I need this for all my parameters].  Or is there some other way to do this? 
 
 Here is my code for looking to see if the record exists:  
public static int ExistInsured(int CaseID, object InsuredLastName, object DateOfBirth, object CurrentAge, object Gender)
{SqlConnection conn = new SqlConnection(connStng.ToString());
SqlCommand cmd = new SqlCommand("SELECT top 1 InsuredID from Insured Where PolicyID = (Select PolicyID from Policy where CaseID = @CaseID) and LastName = @InsuredLastName and DateofBirth = @DateofBirth and Gender = @Gender", conn);
 int result = -1;
cmd.CommandType = CommandType.Text;cmd.Parameters.AddWithValue("@CaseID", CaseID);
cmd.Parameters.AddWithValue("@InsuredLastName", InsuredLastName);cmd.Parameters.AddWithValue("@DateOfBirth", DateOfBirth);
cmd.Parameters.AddWithValue("@CurrentAge", CurrentAge);
cmd.Parameters.AddWithValue("@Gender", Gender);
 
 
conn.Open();
try
{object ret = cmd.ExecuteScalar();
if ((ret != null) && (ret is int))result = (int)ret;
}
finally
{
conn.Close();
}return result;
 
}
 

View 6 Replies View Related

Searching And Displating Records, With A Twist

Nov 28, 2003

ive got a tough one for everyone this time!

i am trying to get a page up that enables me to enter a number into a box on a form, which then on clicking of a search button, queries the database, and returns 2 other fields that relate to the number found in the database, in an ASP datagrid.

the easiest way to do this would be to use OLEDB or ODBC, but the host i am using doesnt support either of them, and so i am trying to use their code, something using OBJDB, but to no avail. frankly, their code is rubbish, and im not sure how to go about doing the above.

i would be very grateful if someone could help me out with this problem,

thanks,

craig

View 1 Replies View Related

Searching Similar Records Within A Table

Oct 8, 2007


Hi,


I have 4 tables :




Code Block
Create Table #Request ( [requestid] int , [stateno] nvarchar(5) , [cityno] int , Callid int, UniqueNo int);
Create Table #RequestDetail(reqdetailid int, [customername] Varchar(20), [customerage] int, requestid int);
Create Table #Call(Callid int,Calltype int,callDetailid int )
Create Table #CallDetail(callDetailId int,empid int)

Insert into #CallDetail VALUES(12123,1)
Insert into #CallDetail VALUES(53423,1)
Insert into #CallDetail VALUES(6532,1)
Insert into #CallDetail VALUES(82323,1)
Insert into #CallDetail VALUES(124235,1)

Insert Into #Call VALUES(111,1,12123)
Insert Into #Call VALUES(112,1,53423)
Insert Into #Call VALUES(114,1,6532)
Insert Into #Call VALUES(123,2,6532)
Insert Into #Call VALUES(134,1,124235)


Insert Into #request Values('324234','SA023',12,111,0);
Insert Into #request Values('223452','SA023',12,112,0);
Insert Into #request Values('456456','SA024',12,114,0);
Insert Into #request Values('22322362','SA024',44,123,0);
Insert Into #request Values('22654392','SA023',12,134,0);

Insert into #requestdetail values(1, 'Bill',23,'324234')
Insert into #requestdetail values(2, 'Tom',25,'223452')
Insert into #requestdetail values(3, 'Bobby',27,'456456')
Insert into #requestdetail values(4, 'Guck',29,'22322362')
Insert into #requestdetail values(5, 'Bobby',33,'22654392')



1. My stored proc will take the CallDetailID.

2. I have to find out the requests made on this calldetail.

3. After getting the request, i want to take the Customername, cityno of the request/requestdetail and pass it again to #request table to search for any duplicates within the request.

4. If found return the details of the original record :

[A similar requirement was solved earlier, but the structure has changed. This is a seperate requirement with different table strucure. Hence a new post. ]


thanks

View 7 Replies View Related

Full Text Searching....THOUSANDS Of Records!

Sep 12, 2005

Hope I am in the correct section.

I am installing a FTS system on an existing system (that used LIKE % queries!!  hahaha)

Anyway, it is working pretty well (AND FAST!) but when I type in a
common word like "damage" I get like 32,000 records.  Now, the
server handles those records in about one second but the ASP page that
returns the results takes about one MINUTE to download.  When I
save the source, it is almost 12 MEGS!!

So, basically, I am streaming 12 megs across the pipe and I want to reduce that.

I would like the system to detect over maybe 500 records and cancel the search.

I have put a "TOP 500" into the search and that actually works pretty well but is there a better/smarter method?

Thanks!

cbmeeks

View 3 Replies View Related

SQL Server 2008 :: Loop Through Date Time Records To Find A Match From Multiple Other Date Time Records?

Aug 5, 2015

I'm looking for a way of taking a query which returns a set of date time fields (probable maximum of 20 rows) and looping through each value to see if it exists in a separate table.

E.g.

Query 1

Select ID, Person, ProposedEvent, DayField, TimeField
from MyOptions
where person = 'me'

Table

Select Person, ExistingEvent, DayField, TimeField
from MyTimetable
where person ='me'

Loop through Query 1 and if it finds ANY matching Dayfield AND Timefield in Query/Table 2, return the ProposedEvent (just as a message, the loop could stop there), if no match a message saying all is fine can proceed to process form blah blah.

I'm essentially wanting somebody to select a bunch of events in a form, query 1 then finds all the days and times those events happen and check that none of them exist in the MyTimetable table.

View 5 Replies View Related

SQL Server 2012 :: Using Select Query To Get 2014-08-09 11:13:03 From Original Date Records?

Aug 18, 2014

I have date field in table and data contain 2014-08-09 11:13:03.340

when I use smalldatefield I am getting 2014-08-09 11:13:00 I should have got 2014-08-09 11:13:03

Why the 03 is trimming in smalldatefield.

how do I use select query to get 2014-08-09 11:13:03 from original Date records

View 1 Replies View Related

Power Pivot :: Divide Number Of Records By End Date Of Month Using DAX Query

Aug 4, 2015

We have some requirement in PowerBI reports. Here we have a table and having Date, Events columns. Below is the sample data..we are creating a measure to calculate the average of the event count for month.We need a measure for calculating Average of Event count per month= sum(Events for a month)/numberofdays in the month.Example for January month : sum(343423)/31 (31 number of days in January) 

When we write this measure using DAX query in Excel we are getting semantic error.Tried sample formula : Average:=SUM([Events])/EOMONTH([EventDate],1)

writing this DAX command for measure.After having this data ready, we are creating PowerBI reports on this data.

View 6 Replies View Related

Failed Searching Records By Using SQLCommand Parameter LIKE '%@keywords%'

Aug 8, 2007

I use SQL Server 2005 Developer. I failed to search the records by using SQLCommand Paramater. Please find the code below.
However, when I hardcode like  LIKE '%sudoku%' , it works. Could aynone help?
Thanks,
Andy.private bool searchProducts(string keywords)
{
.......
command.CommandText = "SELECT Product.ProductID, Product.Name, Product.Image, ProductPrice.Price, ISNULL(SpecialProduct.PromoDiscount,0) as PromoDiscount FROM Product INNER JOIN ProductPrice ON Product.ProductID = ProductPrice.ProductID LEFT OUTER JOIN SpecialProduct ON Product.ProductID = SpecialProduct.ProductID WHERE Product.Name LIKE '%@keywords%' ";
command.Parameters.Add("@keywords", SqlDbType.VarChar, 100);
command.Parameters["@keywords"].Value = keywords;
.............
}

View 3 Replies View Related

T-SQL (SS2K8) :: How To Split One Record Into Multiple Records In Query Based On Start And End Date

Aug 27, 2014

I would like to have records in my Absences table split up into multiple records in my query based on a start and end date.

A random record in my Absences table shows (as an example):

resource: 1
startdate: 2014-08-20 09:00:00.000
enddate: 2014-08-23 13:00:00.000
hours: 28 (= 8 + 8 + 8 + 4)

I would like to have 4 lines in my query:

resource date hours
1 2014-08-20 8
1 2014-08-21 8
1 2014-08-22 8
1 2014-08-23 4

Generating the 4 lines is not the issue; I call 3 functions to do that together with cross apply.One function to get all dates between the start and end date (dbo.AllDays returning a table with only a datevalue column); one function to have these dates evaluated against a work schedule (dbo.HRCapacityHours) and one function to get the absence records (dbo.HRAbsenceHours) What I can't get fixed is having the correct hours per line.

What I now get is:

resource date hours
...
1 2014-08-19 NULL
1 2014-08-20 28
1 2014-08-21 28
1 2014-08-22 28
1 2014-08-23 28
1 2014-08-24 NULL
...

... instead of the correct hours per date (8, 8, 8, 4).

A very simplified extract of my code is:

DECLARE @startdate DATETIME
DECLARE @enddate DATETIME
SET @startdate = '2014-01-01'
SET @enddate = '2014-08-31'
SELECTh.res_id AS Resource,
t.datevalue,
(SELECT ROUND([dbo].[HRCapacityHours] (h.res_id, t.datevalue, t.datevalue), 2)) AS Capacity,
(SELECT [dbo].[HRAbsenceHours] (9538, h.res_id, t.datevalue, t.datevalue + 1) AS AbsenceHours
FROMResources h (NOLOCK)
CROSS APPLY (SELECT * FROM [dbo].[AllDays] (@startdate, @enddate)) t

p.s.The 9538 value in the HRAbsenceHours function refers to the absences-workflowID.I can't get this solved.

View 1 Replies View Related

Searching By A Date Field

Mar 10, 2005

I'm using the .NET Framework 1.1 together with SQL Server 2005 Beta.

I have a search page where you can search a db using a number of fields or combination thereof. Three are text fields (patient id, surname, forename) and I can do any search using one criteria or any combination without any problem.

However, I'd also like to search on a dob (datetime field in SQL Server) and I'm having real problems in making this work. The dates are stored in the following way in SQL Server: '1938-05-31 00:00:00.000', whilst they are displayed as 'dd/mm/yyyy' on a web page, which I guess corresponds to my regional settings.

My code is shown below. I 've tried any number of combinations for the dob string with no success. I do not get any error, just no records are returned.

Does anyone have any idea what I'm doing wrong and how to correct it before this drives me crazy?!


TIA for any help.

P.S. chxPatID, chxSurname etc are all checkboxes.



<code starts>

If chxPatID.Checked Then
strSQL = strSQL & " patid= '" & txtPatID.Text & "' "
strAND = " AND "
End If

If chxSurname.Checked Then
strSQL = strSQL & strAND & " surname ='" & txtSurname.Text & "' "
strAND = " AND "
End If

If chxForename.Checked Then
strSQL = strSQL & strAND & " forename='" & txtForename.Text & "' "
strAND = " AND "
End If

If chxDoB.Checked Then
strSQL = strSQL & strAND & " dob= " & CDate(Year(txtDoB.Text) & "-" & Month(txtDoB.Text) & "-" & Day(txtDoB.Text)) & ""
End If

</code ends>

View 1 Replies View Related

Searching Date Column

May 11, 2004

i have a table date column with smalldatetime format. data looks like
2004-05-10 00:00:00

i can search specify date but i want to retrieve all records for a month for e.g
April
how can i do this?
i tried

select * from mytable
where datecolumn like '%05%'
doesn't seem to work

View 3 Replies View Related

Searching For Only Part Of A Date

Oct 5, 2007

Ok, so I have a Select statement that looks like this:

Select * from FilteredOpportunity
where (OpportunityID LIKE @opportunityid)
and (Name LIKE @name)
and (CustomerIDName LIKE @customeridname)
and isNull(EstimatedCloseDate, '1900-01-01') LIKE @estimatedclosedate
and isNull(Description, '') LIKE @description
and isNull(AccountIdName, '') LIKE @AccountIDName
and isNull(ACCU_OppTypeName, '') LIKE @ACCU_OppTypeName
and isNull(SalesStageCodeName, '') LIKE @SalesStageCodeName
and isNull(ACCU_CustomerTypeName, '') LIKE @ACCU_CustomerTypeName
and (CreatedByName LIKE @CreatedByName)
and (CreatedOn LIKE @CreatedOn)
and isNull(ACCU_OppSourceName, '') LIKE @ACCU_OppSourceName
and (StateCodeName LIKE @StateCodeName)
and (StatusCodeName LIKE @StatusCodeName)

This chunk of code is used in an XML file which, once this XML is imported (using sharepoint by the way if you haven't noticed), I can then search through tables with different filters. Well, my date filter isn't working the same way as my other ones. I have a couple different date filters, but none of them work.

Before I ask my question, I only pass in one variable at a time through my code.... the rest of the variables get a default value passed to them if the user doesn't pass it. That value is simply '%'. Anyways, so the different ways a user can type in a date is by typing in the whole date, part of the date starting with the beginning of it, typing in the end of the date, or typing something within the date. For a string it's like 'Example', 'Exam%', '%ple', and '%amp% respectively. How do I accomplish this with a date?

View 1 Replies View Related

Searching By Date Ranges

Dec 11, 2007

Hello Gang,

I have a strange problem that I haven't dealt with before.

I need to execute a piece of code based on date ranges. If the date range is:

Scenario 1:between 02/28 (Feb 28) and 07/31 (July 31) do x
-----------------------------------------------------------
Scenario 2:between 08/01 (Aug 1) and 01/31 (Jan 31) do y


I am trying to automate a report. The report is supposed to generate a result that will differ based on the date ranges going into the future. E.g.

[1]. If the run date of the report is between '2/1/20xx' and '7/31/20xx' display <ABC> or

[2]. If the run date of the report is between '8/1/20xx' and '1/31/20xx' display <PQR>

In example # 2. I am moving from one year to the next (July to Dec and the one extra month of Jan). So for example, if the guy runs the report between August of 2008 and January of 2009, display <PQR>.

How do I achieve both # 1 & 2 above in a code? Does this explain better.

Joshi

View 1 Replies View Related

Searching Date Range

Feb 23, 2007

i have a date field with which i'd like to search several date ranges. the date field is populated as month, day, year (2/23/2007).

I'd like to select date using the following criteria:

< 30 days (i.e. select * from date where today's date < 30)

30 - 60 days (i.e. select * from date where today's date >= 30 and <= 60)

> 90 days (i.e. select * from date where today's date < 90)

Is there a simple way of acheiving this?

Thanks!

View 1 Replies View Related

Date Searching In Sqlserver 2005

Jan 11, 2008

hi,
i have problem while searching date in datebase using like operator ,i write the below query but this will not give any result and i have the date 13/1/2008 in my table meeting please any one help me.
 
select meetingdate from meeting where meetingdate  like '%13/1/2008%'
 
thanks
prasath

View 4 Replies View Related

SQL DateTime And Searching For Just The Date Portion

Oct 25, 2004

I have a SQL DB with a column called time_occurred that is formatted like ( 7/28/2004 7:10:30 AM ).

What I need to do is run a report based on just the month day and year portion. I am using the calendar control so mins, sec and milliseconds are not available nor do I really need them.

I am running the Query with this Stored Procedure



ALTER PROCEDURE dbo.Prodecure1
(
@WhereClause varchar(8000)
)

AS

-- Create a variable @SQLStatement
DECLARE @SQLStatement varchar(8000)

-- Enter the dynamic SQL statement into the variable @SQLStatement
SELECT @SQLStatement = 'SELECT column1, column2, etc...' +
@WhereClause

-- Execute the SQL statement
EXEC(@SQLStatement)

RETURN

View 1 Replies View Related

Searching For Latest Date And Time Only

Jul 20, 2005

> This is what I want to do with the data table below.[color=blue]>> I only want it to show one id for each issue. ( ie, 4001 only once,> 4002 only once, etc. But only the one with the latest date and time)>> Ie. 4001 should only be in the table once, with the latest date -> which should be :> 400109/12/200317:12:09 (as I only want to show the last time> the id was updated - do you get me now )>> Ie. 4002 should show only 400211/12/200315:25:13>[/color][color=blue]>>> idhs_change_datehs_change_time> 400127/10/200310:38:27> 400109/12/200314:43:58> 400109/12/200317:12:09> 400227/10/200310:56:28> 400209/12/200314:44:11> 400211/12/200315:25:13> 400327/10/200311:13:12> 400309/12/200314:44:21> 400310/12/200310:48:02> 400310/12/200313:25:09> 400427/10/200311:28:09> 400409/12/200314:44:29> 400409/12/200317:18:28> 400527/10/200315:55:40> 400528/10/200310:18:24> 400627/10/200315:59:47> 400628/10/200310:18:38> 400609/12/200314:44:40> 400609/12/200316:47:15>[/color]

View 3 Replies View Related

Running A LIKE Statement When Searching For A Date Field...

Feb 14, 2006

I am trying to run a like statement that has a datetime column and for some reason it does not return any values. I looked in the SQL help files and in states in there that when trying to select using a datetime that the preferred way of doing it is using a like statment. Does anybody know a better way of doing this? Here is my example: (I have dates in this column ie 2006-02-13 11:30:54.220)

SELECT * FROM workorderhistory WHERE wheninstalled LIKE '%2006-02%'

View 7 Replies View Related

SQL 2012 :: Query To Make Single Records From Multiple Records Based On Different Fields Of Different Records?

Mar 20, 2014

writing the query for the following, I need to collapse the continuity. If the termdate for an ID is one day less than the effdate of the next id (for the same ID) i need to collapse the records. See below example .....how should i write the query which will give me the desired output. i.e., get min(effdate) and max(termdate) if termdate is one day less than the effdate of next record.

ID effdate termdate
556868 1999-01-01 1999-06-30
556868 1999-07-01 1999-10-31
556869 2002-10-01 2004-01-31
556872 1999-02-01 2000-08-31
556872 2000-11-01 2004-01-31
556872 2004-02-01 2004-02-29

output should be ......

ID effdate termdate
556868 1999-01-01 1999-10-31
556869 2002-10-01 2004-01-31
556872 1999-02-01 2000-08-31
556872 2000-11-01 2004-02-29

View 0 Replies View Related

Stored Procedure Giving Error When Searching On Date Range

Aug 20, 2007

I've  a report whose columns are returned from a stored procedure. Now I want to display the report based on a date range. The date field is Received. It's in dbo.master. I added 2 parameters start date and end date. When I check the condition if dbo.master.Received>StartDate and dbo.master.Received < EndDate directly I'm getting error. Could someone tell me what mistake I'm doing? Thanks for your help!ALTER Procedure [dbo].[USP_Reports_NewTier1]
 
@ClientCode VARCHAR(7) = '',@UserID INT = 0
,@OrderID INT =0
,@StartDate datetime,@EndDate datetime
 
IF @ClientCode <> '' and dbo.master.Received > StartDate and dbo.master.Received<EndDateBEGIN SELECT --Root Select --ClientName @ClientName = (Select Name  FROM dbo.customer c     WHERE   c.Customer = @ClientCode)     ,@TotalDollarValue = (SELECT SUM(m.current1-m.paid1)     FROM dbo.master m     WHERE phase=1     AND m.Customer = @ClientCode    AND M.Status <> 'PIE')
 ,@AverageAge = ISNULL((select avg(age) from    (select datediff(day,Received,CASE WHEN clidlp>clidlc then clidlp else clidlc END)* -1 as age    from dbo. master M    WHERE phase=1 AND customer = @ClientCode AND M.Status <> 'PIE') x),0)END

View 3 Replies View Related

Comparing Date Records In One Column To Know Missing Date Interval?

Jun 6, 2012

I need to compare the contents of a column.

I have a table with 1 column. Below are the sample contents..

DateInterval
2012-06-01 00:30:00.000
2012-06-01 01:00:00.000
2012-06-01 01:30:00.000
2012-06-01 02:00:00.000
2012-06-01 02:30:00.000

[code]....

as you can see, the records have a 30minutes time interval. i need to create a query to know if there are missing records in the table. so basically the result should be this:

DateInterval
2012-06-01 18:00:00.000
2012-06-01 20:30:00.000

if it is not doable, we can get the nearest record of all missing records like this:

DateInterval
2012-06-01 17:30:00.000
2012-06-01 20:00:00.000

or this:

DateInterval
2012-06-01 18:30:00.000
2012-06-01 21:00:00.000

or this:

DateInterval
2012-06-01 17:30:00.000
2012-06-01 18:30:00.000
2012-06-01 20:00:00.000
2012-06-01 21:00:00.000

View 6 Replies View Related

Sql Query For Searching Database

Jun 14, 2006

Dear Sir,

I am building a website some what like B2B portal using asp.net and access database. I want to provide a search facility to the user through which they can search products in our database.

Can you provide me a strong SQL Query for that. Or is there any other way of doing that.

Please help me.

Thanking You

Suraj

View 2 Replies View Related

What Query Will Return Value Closest To Value Searching For

Mar 27, 2001

i have a column of dates.
i make an index or key for this column so that
i can perform binary search i hope.
If the search is not succesful how do
i get the query to return the two dates
surrounding the date i was searching for.

View 2 Replies View Related

Searching Dates In Query Analyzer

Dec 7, 2007

Hello Gang,

I have a strange problem that I haven't dealt with before.

I need to execute a piece of code based on date ranges. If the date range is:

Scenario 1:between 02/28 (Feb 28) and 07/31 (July 31) do x
-----------------------------------------------------------
Scenario 2:between 08/01 (Aug 1) and 01/31 (Jan 31) do y

Can anyone help me with this code. I am having a SCD (Stupid Coder Day) and can't seem to do anything that is scalable - like accounting for leap years (Feb issue) and the fact that Scenario # 2 above is between 2 different calender years.

Your help is much appreciated.

JJOSHI

View 3 Replies View Related

Searching Dates In Query Analyzer

Dec 11, 2007

Hello Gang,

I have a strange problem that I haven't dealt with before.

I need to execute a piece of code based on date ranges. If the date range is:

Scenario 1:between 02/28 (Feb 28) and 07/31 (July 31) do x
-----------------------------------------------------------
Scenario 2:between 08/01 (Aug 1) and 01/31 (Jan 31) do y


I am trying to automate a report. The report is supposed to generate a result that will differ based on the date ranges going into the future. E.g.

[1]. If the run date of the report is between '2/1/20xx' and '7/31/20xx' display <ABC> or

[2]. If the run date of the report is between '8/1/20xx' and '1/31/20xx' display <PQR>

In example # 2. I am moving from one year to the next (July to Dec and the one extra month of Jan). So for example, if the guy runs the report between August of 2008 and January of 2009, display <PQR>.

How do I achieve both # 1 & 2 above in a code? Does this explain better.

View 4 Replies View Related

How To Do Case Sensitive Query Searching?

Jan 20, 2008



Hi,

How do you do a case sensitive searching without having the database case sensitive or is this even possible. There are times we want to perform case sensitive searching and case insensitive searching.

I found this article, but is that the suggested way. seems a bit bad, but if it is the way I am willing to use it.

http://sqlserver2000.databases.aspfaq.com/how-can-i-make-my-sql-queries-case-sensitive.html

Thanks,
Matt

View 5 Replies View Related

Datetime Problems With A Searching Query

Aug 22, 2006

hi;

i want to get some results for new my stored proce is below;

create Procedure HaberleriGetir

@Kelime varchar(50),

@tarih1 smalldatetime,

@tarih2 smalldatetime,

@KatID int,

@lang char(5)

as

if @lang = 'Hepsi'

select * from Haberler where HKatID = @KatID and Metin like %@Kelime% or Baslik like %@Kelime% and Tarih between @tarih1 and @tarih2

else

select * from Haberler where HKatID = @KatID and lang = @lang and Metin like %@Kelime% or Baslik like %@Kelime% and Tarih between @tarih1 and @tarih2



incorrect near @Kelime....

and i can't get a result between two dates like @tarih1 & @tarih2







View 2 Replies View Related

Query For Searching 'names' Based On First Letter

Apr 2, 2004

I would like to search MySQL table for names by selecting the first letter of the name.
eg: SELECT * FROM names WHERE lastName "begins with" M (or Mi, etc)

Right now if I use LIKE I get all names that contain "M".

Thanks.
PeterM

View 2 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved