Results 1 to 5 of 5

Thread: How do I insert todays date using sql

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Feb 2000
    Location
    Medford,MA,USA
    Posts
    23
    I have an access table and I want to insert today's date into one of the field. What is the correct syntax.
    This is not working:
    Dim todaysdate as String
    todaysdate = format(Now,"m/d/yy")
    Insert into table(Date)Values(todaysdate)
    Thanks

  2. #2
    Serge's Avatar
    Join Date
    Feb 1999
    Location
    Scottsdale, Arizona, USA
    Posts
    2,744
    What seaweed has said is right, the only thing is, it is to be used in Client/Server database, not Access.
    GetDate function is a Transact SQL function, but in Access you CAN use Date(), Time(), Now() functions. Just bear in mind that you can not use the function by itself, i.e:

    Code:
    Select Date() As MyDate From MyTable
    You have to use it in combination with a real fields, i.e:

    Code:
    Select FieldName, Date() As MyDate From MyTable

  3. #3
    Frenzied Member
    Join Date
    Jan 2000
    Location
    Bellevue, WA, USA
    Posts
    1,357

    Oops

    Well, I deleted my first reply because I re-read the question and saw that he was talking about Access, not SQL server. It's been a while since I've done access, but I'm looking into it now...

    ~seaweed

  4. #4
    New Member
    Join Date
    Feb 2000
    Posts
    12

    Dates in Access

    Hi..
    I've inserted a date once using SQL and VB, And you have to do something freaky..

    Make sure the SQL looks something like this:

    SQL = "insert into Table Values( # "& date & " #)"

    I cant seem to find the actual syntax (you may want to double check the double quotes and see if any single quotes are needed), but I know that you need the # before a date field for it to be properly accepted into access

    hope that helps!

    ~Sam



  5. #5
    Lively Member
    Join Date
    Jul 1999
    Posts
    78
    Sam's got the right idea; his Syntax is correct as well.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width