Welcome to SPN

Register and Join the most happening forum of Sikh community & intellectuals from around the world.

Sign Up Now!
  1. Monthly (Recurring) Target: $300 :: Achieved: $95
      Become a Supporter    ::   Make a Contribution   

Current date in a table field

Discussion in 'Information Technology' started by msanewbee, Jul 28, 2006.

  1. msanewbee

    msanewbee
    Expand Collapse
    Guest

    Is there a way to have the current date automatically put in a table field
    whenever a new record is created?
     
  2. Loading...


  3. xRoachx

    xRoachx
    Expand Collapse
    Guest

    Hi -- In design view, add the following to the default value for the date
    field:
    Date()



    "msanewbee" wrote:

    > Is there a way to have the current date automatically put in a table field
    > whenever a new record is created?
     
  4. msanewbee

    msanewbee
    Expand Collapse
    Guest

    That works perfect. Thanks!! :)

    "xRoachx" wrote:

    > Hi -- In design view, add the following to the default value for the date
    > field:
    > Date()
    >
    >
    >
    > "msanewbee" wrote:
    >
    > > Is there a way to have the current date automatically put in a table field
    > > whenever a new record is created?
     
  5. Jamie Collins

    Jamie Collins
    Expand Collapse
    Guest

    msanewbee wrote:
    > Is there a way to have the current date automatically put in a table field
    > whenever a new record is created?


    Use either NOW() or DATE() as the column's default value e.g.

    Sub effective_date()
    Kill "C:\DropMe.mdb"
    Dim cat
    Set cat = CreateObject("ADOX.Catalog")
    With cat
    .Create _
    "Provider=Microsoft.Jet.OLEDB.4.0;" & _
    "Data Source=C:\DropMe.mdb"
    With .ActiveConnection

    ' Create test table
    .Execute _
    "CREATE TABLE Test4 (key_col INTEGER NOT" & _
    " NULL UNIQUE, effective_date DATETIME DEFAULT" & _
    " NOW() NOT NULL); "

    ' Create test row (default gets applied)
    .Execute _
    "INSERT INTO Test4 (key_col) VALUES (1);"

    ' Show results
    Dim rs
    Set rs = .Execute( _
    "SELECT key_col, effective_date" & _
    " FROM Test4;")
    MsgBox rs.GetString
    rs.Close
    End With
    Set .ActiveConnection = Nothing
    End With
    End Sub

    Jamie.

    --
     
Since you're here... we have a small favor to ask...

More people are visiting & reading SPN than ever but far fewer are paying to sustain it. Advertising revenues across the online media have fallen fast. So you can see why we need to ask for your help. Donating to SPN's is vote for free speech, for diversity of opinions, for the right of the people to stand up to religious bigotry. Without any affiliation to any organization, this constant struggle takes a lot of hard work to sustain as we entirely depend on the contributions of our esteemed writers/readers. We do it because we believe our perspective matters – because it might well be your perspective, too... Fund our efforts and together we can keep the world informed about the real Sikh Sikhi Sikhism. If everyone who writes or reads our content, who likes it, helps us to pay for it, our future would be much more secure. Every Contribution Matters, Contribute Generously!

    Become a Supporter      ::     Make a Contribution     



Share This Page