i'm using stored procedure in SQL server,i need to prinf of get current datetime(eg 2012-16-05 03:10:00) in the format of
"05/16/2012 00:00:00" please help me
thanks in advance.......
Loading
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Jiteendra SampathiraoRank #585 · 4.1K reputationPosted May 16, 2012, 2:03 AM EDT
Go through this link...
http://blog.sqlauthority.com/2008/08/14/sql-server-get-date-time-in-any-format-udf-user-defined-functions/
Hope it resolves your problem...
Kunal VaishyaRank #990 · 2K reputationPosted May 16, 2012, 2:12 AM EDT
this On GetDate() you can set your Own date variable
Select Convert(varchar,Getdate(),101) + ' ' + Convert(varchar,Getdate(),8)
Or
Declare @dt DateTime
Set @dt =Getdate()
Select Convert(varchar,@dt,101) + ' ' + Convert(varchar,@dt,8)
SenthilkumarRank #387 · 6.5K reputationPosted May 16, 2012, 3:53 AM EDT
There are two types of functions which tells you how to convert the date time in desired format.
1) Convert
2) Cast
The Convert is standard and most commonly used.
Convert(conversiondatatype, actualdate,format-code)
For example,
CONVERT(VARCHAR,GETDATE(),108)
Please refer this table for format code.