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.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
SenthilkumarPosted May 16, 2012, 7:53 AM
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.
Kunal VaishyaPosted May 16, 2012, 6:12 AM
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)
Jiteendra SampathiraoPosted May 16, 2012, 6:03 AM
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...