• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 358
  • Last Modified:

MS SQL

sql DATETIME DEFAULT  getdate(), 'yyyy/MM/dd hh:mm:ss tt', 'en-US' ); ();



i want to make a default date when i insert new record in database
only i need to insert required field like username and password and automatically the datetime will be insert as default in each insertion  

how i can do it ? in sql
0
AFIF JABADO
Asked:
AFIF JABADO
  • 4
  • 3
1 Solution
 
Lee SavidgeCommented:
If you want the value inserted automatically when adding a record to the table then you need to set the default property:

ALTER TABLE myTable ADD  DEFAULT (getdate()) FOR myColumn
0
 
AFIF JABADOAuthor Commented:
i know this .. i want specific format in default datetime   like this ..  DEFAULT  getdate(), 'yyyy/MM/dd hh:mm:ss tt', 'en-US' ); ()
0
 
AFIF JABADOAuthor Commented:
I've requested that this question be deleted for the following reason:

i have found the solution from sql server ebook
0
Cloud Class® Course: MCSA MCSE Windows Server 2012

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

 
Lee SavidgeCommented:
What is tt?
0
 
Lee SavidgeCommented:
If you have found a solution, post it so others can benefit and then accept your own answer. Don't delete the question.
0
 
AFIF JABADOAuthor Commented:
http://www.sql-server-helper.com/tips/date-formats.aspx

u choose your format from this table and u select the date and u will be in what format u need for example in the table sms  whe have a field datein

DD/MM/YYYY HH:MI:SS:MMMAM       Kuwaiti       SELECT CONVERT(VARCHAR(25), GETDATE(), 131)       28/04/2006 12:39:32:429AM


SELECT CONVERT(VARCHAR(25), datein, 131)
0
 
AFIF JABADOAuthor Commented:
The date on sql server will be stored as Data type : datetime
than if you want to convert it to another format you should choose a function to convert to your format and the link below http://www.sql-server-helper.com/tips/date-formats.aspx
help you in choosing format type.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Microsoft Office 2010

This course will introduce you to the interfaces and features of Microsoft Office 2010 Word, Excel, PowerPoint, Outlook, and Access. You will learn about the features that are shared between all products in the Office suite, as well as the new features that are product specific.

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now