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

MS SQL Row Create Date

Dear Sir,

I have create in my table one column namely JobOpenDate, I want SQL server automatically insert date when, in which date row was create for which I have used following commands on formula column (convert(varchar(10),getdate(),111)), filed name is ODate Datatype is varchar(10).

But every day its take current date and insert in the column instead of just show only row create date.

Rgds.
Iqbal
0
Mehram
Asked:
Mehram
  • 2
  • 2
1 Solution
 
Anthony PerkinsCommented:
You are using the Formula property this is intended for computed columns.  You need to use the Default property and if JobOpenDate is a datetime column just use GETDATE()
0
 
MehramAuthor Commented:
Sir, when I am using this it is also taking time, which is not required in my case. Please help.
0
 
Anthony PerkinsCommented:
Ok.  If the JobOpenDate is a datetime and you do not need the time than you can place the following in the Default attribute:
CAST(CONVERT(char(10), GETDATE(), 120) as datetime)

If on the other hand the database is varchar(10) and you want it with the Japan style than use:
CONVERT(char(10), GETDATE(), 111)
0
 
MehramAuthor Commented:
Sir, Thanks my problem resolved.
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

Get 10% Off Your First Squarespace Website

Ready to showcase your work, publish content or promote your business online? With Squarespace’s award-winning templates and 24/7 customer service, getting started is simple. Head to Squarespace.com and use offer code ‘EXPERTS’ to get 10% off your first purchase.

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