4 Replies - 4999 Views - Last Post: 06 May 2008 - 01:13 AM

#1 MIKE2098  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 9
  • Joined: 05-May 08

Adding Date field in MS SQL

Posted 05 May 2008 - 04:54 AM

I want to add a date field to my table I have tried [Date] datetime but it resets to Date or [Date]]]

I have a simple table

USERS

userID Int NOTNULL
Email VarChar NOTNULL
Date datetime NOTNULL

Driving me mad I just want a date/time to be added when a userID and email address is added.

I am ussing VB 2005 SQL Express/MSSMSE on Vista x64

or do I just need to create a table as it defaults too and add code to generate date

i.e.

Dim date1 As DateTime
date1 = Now()
TextBoxDate = date1


thanks M

Is This A Good Question/Topic? 0
  • +

Replies To: Adding Date field in MS SQL

#2 PsychoCoder  Icon User is offline

  • Google.Sucks.Init(true);
  • member icon

Reputation: 1639
  • View blog
  • Posts: 19,853
  • Joined: 26-July 07

Re: Adding Date field in MS SQL

Posted 05 May 2008 - 06:10 AM

If you are just wanting to default your column to the current datetime use GETDATE()
Was This Post Helpful? 0
  • +
  • -

#3 MIKE2098  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 9
  • Joined: 05-May 08

Re: Adding Date field in MS SQL

Posted 05 May 2008 - 01:01 PM

View PostPsychoCoder, on 5 May, 2008 - 06:10 AM, said:

If you are just wanting to default your column to the current datetime use GETDATE()



Sorry where do I use GETDATE() in the table or on the form ?

thanks
Was This Post Helpful? 0
  • +
  • -

#4 PsychoCoder  Icon User is offline

  • Google.Sucks.Init(true);
  • member icon

Reputation: 1639
  • View blog
  • Posts: 19,853
  • Joined: 26-July 07

Re: Adding Date field in MS SQL

Posted 05 May 2008 - 06:36 PM

If you want it to default to the current date, in Enterprise Manager where it says Default Value for that column in that table (right click on the table and select Design) then select that column, down below will be a Default Value section, add GETDATE() on that line.
Was This Post Helpful? 0
  • +
  • -

#5 MIKE2098  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 9
  • Joined: 05-May 08

Re: Adding Date field in MS SQL

Posted 06 May 2008 - 01:13 AM

View PostPsychoCoder, on 5 May, 2008 - 06:36 PM, said:

If you want it to default to the current date, in Enterprise Manager where it says Default Value for that column in that table (right click on the table and select Design) then select that column, down below will be a Default Value section, add GETDATE() on that line.


Thanks for that I knew it was somthing simple.

how would I query the db to see if the user id is already in the DB ?

Is there a way to run aselect statement that will output to a text file or even better an email with the results and a way of flagging the DB so if a user details have been stored or sent it will not send them again

somthing like

select email/date from Users where date > 4400

not sure if this is a VB or sql question sorry

thanks

This post has been edited by MIKE2098: 06 May 2008 - 01:37 AM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1