Please start any new threads on our new site at We've got lots of great SQL Server experts to answer whatever question you can come up with.

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
Save Password
Forgot your Password?

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Date issues
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic
Starting Member

36 Posts

Posted - 07/16/2011 :  10:50:44  Show Profile  Reply with Quote
(1) why doesn't my date field auto populate the current system time when creating a new record? i use(getdate()) in sql server (default value or binding column property. the date's datatype is datetime.

(2) my website is hosted in US - thus capturing US time. Ex:

UK: 2011-07-15 21:05:30.630
US: 2011-07-15 13:05:30.630

i need a way to take current time and - 8hours hence it becomes UK time.

Aged Yak Warrior

819 Posts

Posted - 07/16/2011 :  11:21:56  Show Profile  Reply with Quote
What is the code you are using to insert the new row? If you are specifying anything for that column, the default value will not be used.
Go to Top of Page
Starting Member

36 Posts

Posted - 07/16/2011 :  11:38:22  Show Profile  Reply with Quote

i'm not writing any code for it and not passing in any values. i simply want it to auto populate the column when a record is created.
Go to Top of Page
Starting Member

36 Posts

Posted - 07/16/2011 :  14:00:43  Show Profile  Reply with Quote
ok i just noticed that it does create the time /date when i manually insert a new record.

my code to create the record is using c#

DatabaseLayerDataContext db = new DatabaseLayerDataContext();

                Comment comments = new Comment();
                comments.Title = ddlTitle.SelectedValue;
                comments.FirstName = txtFirstName.Text;
                comments.LastName = txtLastName.Text;
                comments.Message = txtMessage.Text;
                lblDisplayMessage.Text = "Thank you for your message. We will deal with this as soon as possible.";
            catch (Exception err)
                lblDisplayMessage.Text = "An error occurred - please try again later. Thank you for your patience.";
                Console.WriteLine("{0}", err.Message);
Go to Top of Page
Starting Member

36 Posts

Posted - 07/16/2011 :  19:03:41  Show Profile  Reply with Quote
fixed. issue was the code. linq to sql in .net doesn't support auto generated values in db other than identity seed.
Go to Top of Page
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.05 seconds. Powered By: Snitz Forums 2000