• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 354
  • 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
afifosh
Asked:
afifosh
  • 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
 
afifoshAuthor 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
 
afifoshAuthor Commented:
I've requested that this question be deleted for the following reason:

i have found the solution from sql server ebook
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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
 
afifoshAuthor 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
 
afifoshAuthor 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

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

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