ASP Dates Display

J

JP SIngh

Hi All

I have a tricky question wonder if anyone can help.

I store dates in my table as

FDate TDate NoDays


Where Fdate is From Date
TDate is To Date
NoDays is number of days.

We use this to record holidays for our employees.

I would like to write a SQL query which will display all the records where
Fdate or Tdate are within the current month. Not very good at writing SQL
hence need some help.

Some sample data can be like this

Fdate TDate NoDays
15/05/04 18/5/04 4
29/04/04 2/5/04 5
29/5/04 3/06/04 4

If that was the data in the my table and running this query I would expect
it include all the three records when searching for month of "May" as all
three records have atleast one day which falls in the month of May

thanks for your help

Jas
 
B

Bullschmidt

Assuming use of an Access database something like this SQL string should
work to get all the FDate's and TDate's within the current month:

strSQL = "SELECT * FROM MyTable WHERE (FDate >= #" &
DateSerial(Year(Date()), Month(Date(), 1) & "#) AND (FDate < #" &
DateSerial(Year(Date()), Month(Date() + 1, 1) & "#) AND (TDate >= #" &
DateSerial(Year(Date()), Month(Date(), 1) & "#) AND (TDate < #" &
DateSerial(Year(Date()), Month(Date() + 1, 1) & "#)"

Best regards,
J. Paul Schmidt, Freelance ASP Web Designer
http://www.Bullschmidt.com
ASP Designer Tips, ASP Web Database Demo, Free ASP Bar Chart Tool...


*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!
 
G

Gervin

select * from table where month(FDate) = month(getdate()) or month(TDate) =
month(getdate())
 
R

Rags

Hi

Use this query

Select * from <your table>
Where Month(TDate)=5 and Month(FDate)=5

Regards
Rags
 
A

Aaron [SQL Server MVP]

SQL Server, Access, FoxPro, Sybase, Oracle, DB2, MySQL, Firebird, ...?

Preferably you can do this in the database without worrying about silly date
formatting within ASP. However, the database vendor, product and version
will be useful information in providing an answer.
 
J

JP SIngh

Using Access 2000

thanks


Aaron said:
SQL Server, Access, FoxPro, Sybase, Oracle, DB2, MySQL, Firebird, ...?

Preferably you can do this in the database without worrying about silly date
formatting within ASP. However, the database vendor, product and version
will be useful information in providing an answer.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top