Hi Friends,
Could you tell me how to add text in a select statement.
For eg:
SELECT ((datepart(MM,CURRENT_TIMESTAMP)+ '-'
+(datepart(dd,CURRENT_TIMESTAMP) + '-' +
datepart(yyyy,CURRENT_TIMESTAMP))AS
"CURRENT_DATE"
.............ofcourse,this is not correct but it reflects my idea.
Thanks & Regards
DuttSeems you got the general idea. The problem is that DATEPART returns some integer value and you
cannot concatenate that with a string (the string will be converted to an int which will fail). So
you would have to do a CAST around each DATEPART call to make it some char or varchar. But check
first if there already exists a format for the CONVERT function that has the formatting you desire
(check the 3:rd parameter in Books Online).
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
Blog: http://solidqualitylearning.com/blogs/tibor/
"Dutt" <Mr.Dutt@.gmail.com> wrote in message
news:1140021331.883831.135940@.g14g2000cwa.googlegroups.com...
> Hi Friends,
> Could you tell me how to add text in a select statement.
> For eg:
> SELECT ((datepart(MM,CURRENT_TIMESTAMP)+ '-'
> +(datepart(dd,CURRENT_TIMESTAMP) + '-' +
> datepart(yyyy,CURRENT_TIMESTAMP))AS
> "CURRENT_DATE"
> .............ofcourse,this is not correct but it reflects my idea.
> Thanks & Regards
> Dutt
>|||Thanks Tibor,
Its really useful link....It worked .
No comments:
Post a Comment