getting a record thet is between 2 dates[Answered] RSS

5 replies

Last post Jun 03, 2013 05:10 AM by angutar

• angutar

Member

1 Points

3 Posts

getting a record thet is between 2 dates

May 31, 2013 04:05 AM|angutar|LINK

het guys

my employer wants to have a form that gets you the expenses between 2 dates.

i have looked a lot on the internet but i couldn't find anything that could solve my problem.

because the problem is that the 2 dates only have a specified month and year and both are in a different field.

• oned_gk

All-Star

52433 Points

15637 Posts

Re: getting a record thet is between 2 dates

May 31, 2013 04:19 AM|oned_gk|LINK

`SELECT * FROM YOURTABLE WHERE DATEFIELD BETWEEN @START AND @FINIST`

Programming to simplify, don't look for difficult way
Suwandi - Non Graduate Programmer
• angutar

Member

1 Points

3 Posts

Re: getting a record thet is between 2 dates

May 31, 2013 05:23 AM|angutar|LINK

that i know.

but how to be able to only need to specify year and month that come from 2 different date fields

• mishra.bhupe...

Participant

1181 Points

405 Posts

Re: getting a record thet is between 2 dates

May 31, 2013 05:59 AM|mishra.bhupesh|LINK

Try  it:

select Fields
from TableName
where (select [MM/YYYY] = right(convert(varchar(10),Date_Field_In_TABLE,103),7))
between (select [MM/YYYY] = right(convert(varchar(10),StartDate,103),7)) and (select [MM/YYYY] = right(convert(varchar(10),ENDDATE,103),7))

Note: StartDate , ENDDATE  can have formate of dd/MM/yyyy or MM/yyyy doesn't matter.

• oned_gk

All-Star

52433 Points

15637 Posts

Re: getting a record thet is between 2 dates

May 31, 2013 06:14 AM|oned_gk|LINK

where year(datefield)=@Year and Month(datefield )=@Month
Programming to simplify, don't look for difficult way
Suwandi - Non Graduate Programmer
• angutar

Member

1 Points

3 Posts

Re: getting a record thet is between 2 dates

Jun 03, 2013 05:10 AM|angutar|LINK

thanks