Working with dates...

Discussion in 'ASP General' started by Noozer, Jul 1, 2005.

  1. Noozer

    Noozer Guest

    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>??
     
    Noozer, Jul 1, 2005
    #1
    1. Advertising

  2. Noozer

    Noozer Guest

    "John Blessing" <jb@**REMOVE**THIS**Lbesoftware.com> wrote in message
    news:s2axe.14431$...
    > "Noozer" <> wrote in message
    > news:LI7xe.137500$El.57669@pd7tw1no...
    > > 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>??
    > >
    > >

    > 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?
     
    Noozer, Jul 1, 2005
    #2
    1. Advertising

  3. Noozer wrote:
    > 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

    --
    Microsoft MVP - ASP/ASP.NET
    Please reply to the newsgroup. This email account is my spam trap so I
    don't check it very often. If you must reply off-line, then remove the
    "NO SPAM"
     
    Bob Barrows [MVP], Jul 1, 2005
    #3
  4. Noozer

    Noozer Guest

    Noozer, Jul 2, 2005
    #4
  5. Noozer

    Phill. W Guest

    "Noozer" <> wrote in message
    news:LI7xe.137500$El.57669@pd7tw1no...
    > 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.
     
    Phill. W, Jul 5, 2005
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. David Lozzi

    Dates dates dates dates... SQL and ASP.NET

    David Lozzi, Sep 29, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    904
    Rob Schieber
    Sep 30, 2005
  2. PW

    Dates! Dates! Dates!

    PW, Aug 7, 2004, in forum: ASP General
    Replies:
    4
    Views:
    231
    Mark Schupp
    Aug 9, 2004
  3. Replies:
    1
    Views:
    236
    Jano Svitok
    Jul 17, 2007
  4. kellygreer1

    RFC-822 dates into Ruby dates

    kellygreer1, Jun 8, 2008, in forum: Ruby
    Replies:
    1
    Views:
    257
    Eric I.
    Jun 8, 2008
  5. Dr J R Stockton

    FAQ Dates; Opera Dates.

    Dr J R Stockton, Jun 18, 2007, in forum: Javascript
    Replies:
    0
    Views:
    188
    Dr J R Stockton
    Jun 18, 2007
Loading...

Share This Page