Working with dates...

N

Noozer

I'm using ASP to access an MS Access database. One issue that I'm constantly
having problems with is Date/Time records.

What I'd like to know is how does one work with date variables in ASP?

My current problem is this...

I have two variables, Mnth and Yr, which each hold an integer. Mnth holds
between 1 and 12 ( a month ), and Yr holds the desired year (2005 for
example).

With only these two variables how can I generate a full date to use in an
SQL query, such as:

SELECT * From Table WHERE DateAdded>??<date value here>??
 
N

Noozer

John Blessing said:
Use a column type of datetime instead.

The column already is a DateTime... My problem is that my code only has a
month and year stored in variables. How do I convert that to a date to make
a valid comparison against the DateTime column?
 
B

Bob Barrows [MVP]

Noozer said:
I'm using ASP to access an MS Access database. One issue that I'm
constantly having problems with is Date/Time records.

What I'd like to know is how does one work with date variables in ASP?

My current problem is this...

I have two variables, Mnth and Yr, which each hold an integer. Mnth
holds between 1 and 12 ( a month ), and Yr holds the desired year
(2005 for example).

With only these two variables how can I generate a full date to use
in an SQL query, such as:

SELECT * From Table WHERE DateAdded>??<date value here>??

Read these and come back if you have further questions on the topic:
http://www.aspfaq.com/show.asp?id=2313 vbscript
http://www.aspfaq.com/show.asp?id=2040 help with dates
http://www.aspfaq.com/show.asp?id=2260 dd/mm/yyy confusion

Bob Barrows
 
P

Phill. W

Noozer said:
I have two variables, Mnth and Yr, which each hold an integer.
Mnth holds between 1 and 12 ( a month ), and Yr holds the desired
year (2005 for example).

With only these two variables how can I generate a full date to use in an
SQL query, such as:

sSQL = "SELECT col1, col2, col3, ... " _
& "FROM Table1 " _
& "WHERE DateAdded >= #" _
& "#" & Right( "000" & Yr, 4 ) _
& "-" & Right( "0" & Mnth, 2 ) _
& "-" & "01" & "# "

HTH,
Phill W.
 

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

No members online now.

Forum statistics

Threads
473,763
Messages
2,569,562
Members
45,038
Latest member
OrderProperKetocapsules

Latest Threads

Top