Very easy?? How do I put today's date into SQL Server using ASP?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Phil Powell

    Very easy?? How do I put today's date into SQL Server using ASP?

    The date field I believe is of type datetime, but I'm sorry I have
    absolutely no idea how to put today's date into a datetime column
    using ASP and SQL Server.

    Folks, I'm a LINUX guy!!! This is a project I have to get done today
    and that is about the only thing snagging it from being done before
    COB today.

    Please help.

    Thanx
    Phil
  • Aaron Bertrand - MVP

    #2
    Re: Very easy?? How do I put today's date into SQL Server using ASP?

    If you want the date and time,

    INSERT table(column) VALUES(CURRENT_ TIMESTAMP)

    If you just want the date:

    INSERT table(column) VALUES({fn CURDATE()})

    Better yet, make this the default for the table, then you don't even have to
    mention that table in the INSERT statement... try this out in query
    analyzer.

    CREATE TABLE blat
    (
    foo INT,
    bar SMALLDATETIME DEFAULT {fn CURDATE()},
    splunge DATETIME DEFAULT CURRENT_TIMESTA MP
    )
    INSERT blat(foo) VALUES(1)
    INSERT blat(foo) VALUES(2)
    SELECT foo, bar, splunge FROM blat
    DROP TABLE blat

    And for future db-related questions, please post to the asp.db group.

    --
    Aaron Bertrand
    SQL Server MVP





    "Phil Powell" <soazine@erols. com> wrote in message
    news:1cdca2a7.0 402161311.52524 917@posting.goo gle.com...[color=blue]
    > The date field I believe is of type datetime, but I'm sorry I have
    > absolutely no idea how to put today's date into a datetime column
    > using ASP and SQL Server.
    >
    > Folks, I'm a LINUX guy!!! This is a project I have to get done today
    > and that is about the only thing snagging it from being done before
    > COB today.
    >
    > Please help.
    >
    > Thanx
    > Phil[/color]


    Comment

    • Peter Foti

      #3
      Re: Very easy?? How do I put today's date into SQL Server using ASP?

      "Phil Powell" <soazine@erols. com> wrote in message
      news:1cdca2a7.0 402161311.52524 917@posting.goo gle.com...[color=blue]
      > The date field I believe is of type datetime, but I'm sorry I have
      > absolutely no idea how to put today's date into a datetime column
      > using ASP and SQL Server.
      >
      > Folks, I'm a LINUX guy!!! This is a project I have to get done today
      > and that is about the only thing snagging it from being done before
      > COB today.[/color]

      Hi Phil,

      Try these articles:




      Regards,
      Peter Foti


      Comment

      • The Nordic One

        #4
        Re: Very easy?? How do I put today's date into SQL Server using ASP?

        I'm sorry but the articles you posted, albeit futuristically helpful,
        just don't tell me how to insert a date, at least that makes sense to
        me.

        All I want to do is insert a date into a SQL Server datetime column,
        nothing more, in fact, I want to insert the current date, which I assume
        is the VBScript function Now(), if I'm correct..

        would it not be:

        "#" & Now() & "#"

        or is it

        "'" & Now() & "'"

        Phil

        ---------------------------------------
        TCL and PHP: The Superior Web Languages!
        Javascript: Is Cool
        ASP: why?


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

        Comment

        • Aaron Bertrand - MVP

          #5
          Re: Very easy?? How do I put today's date into SQL Server using ASP?

          > "#" & Now() & "#"[color=blue]
          >
          > or is it
          >
          > "'" & Now() & "'"[/color]

          Neither. If you do it this way, you rely on the web server's time being
          correct, for starters, and also being in a format acceptable to SQL Server.
          Did you see my other post?


          Comment

          • middletree

            #6
            Re: Very easy?? How do I put today's date into SQL Server using ASP?

            The # signs are for Access, not SQL Server.

            Now will give you datetime. Some of your post says you want the date only,
            so you can strip out the time with DateValue:

            dtEntryDateTime = Now()
            dtEntryDate = DateValue(dtEnt ryDateTime)

            Other than that, Aaron's post answered your question quite nicely



            "The Nordic One" <det_email_gar_ till_null@null. com> wrote in message
            news:e5zhNmN9DH A.2760@TK2MSFTN GP09.phx.gbl...[color=blue]
            > I'm sorry but the articles you posted, albeit futuristically helpful,
            > just don't tell me how to insert a date, at least that makes sense to
            > me.
            >
            > All I want to do is insert a date into a SQL Server datetime column,
            > nothing more, in fact, I want to insert the current date, which I assume
            > is the VBScript function Now(), if I'm correct..
            >
            > would it not be:
            >
            > "#" & Now() & "#"
            >
            > or is it
            >
            > "'" & Now() & "'"
            >
            > Phil
            >
            > ---------------------------------------
            > TCL and PHP: The Superior Web Languages!
            > Javascript: Is Cool
            > ASP: why?
            > http://valsignalandet.com
            >
            > *** Sent via Developersdex http://www.developersdex.com ***
            > Don't just participate in USENET...get rewarded for it![/color]


            Comment

            • Julian Roberts

              #7
              Re: Very easy?? How do I put today's date into SQL Server using ASP?

              You could give the field a default value of getdate() in the db.

              --
              Jules

              Charon Cart 3
              Shopping Cart Extension for Dreamweaver MX/MX 2004





              Comment

              Working...