Welcome to Dream.In.Code
Getting Help is Easy!

Join 105,765 Programmers for FREE! Ask your question and get quick answers from experts. There are 1,604 online right now! We've got more than 500 tutorials and 2,000 snippets. Join and find out why Dream.In.Code is the #1 programming help community on the internet! Registration is fast and FREE... Join Now!



Adding Date field in MS SQL

 
Reply to this topicStart new topic

Adding Date field in MS SQL

MIKE2098
post 5 May, 2008 - 04:54 AM
Post #1


New D.I.C Head

*
Joined: 5 May, 2008
Posts: 3


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.

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


thanks M



User is offlineProfile CardPM

Go to the top of the page


PsychoCoder
post 5 May, 2008 - 06:10 AM
Post #2


DIC.Rules == true;

Group Icon
Joined: 26 Jul, 2007
Posts: 7,030



Thanked 47 times

Dream Kudos: 7600

Expert In: VB, VB.Net, C#, SQL, ASP, ASP.Net, Web Development, HTML, CSS, Win32 API, Javascript, mySQL, J#, GDI

My Contributions


If you are just wanting to default your column to the current datetime use GETDATE()
User is online!Profile CardPM

Go to the top of the page

MIKE2098
post 5 May, 2008 - 01:01 PM
Post #3


New D.I.C Head

*
Joined: 5 May, 2008
Posts: 3

QUOTE(PsychoCoder @ 5 May, 2008 - 06:10 AM) *

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
User is offlineProfile CardPM

Go to the top of the page

PsychoCoder
post 5 May, 2008 - 06:36 PM
Post #4


DIC.Rules == true;

Group Icon
Joined: 26 Jul, 2007
Posts: 7,030



Thanked 47 times

Dream Kudos: 7600

Expert In: VB, VB.Net, C#, SQL, ASP, ASP.Net, Web Development, HTML, CSS, Win32 API, Javascript, mySQL, J#, GDI

My Contributions


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.
User is online!Profile CardPM

Go to the top of the page

MIKE2098
post 6 May, 2008 - 01:13 AM
Post #5


New D.I.C Head

*
Joined: 5 May, 2008
Posts: 3

QUOTE(PsychoCoder @ 5 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.


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: 6 May, 2008 - 01:37 AM
User is offlineProfile CardPM

Go to the top of the page

Fast ReplyReply to this topicStart new topic
Time is now: 8/21/08 02:32PM

Live Help!

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month