August 24, 2012 at 7:10 am
I would like to show the month of the date-time stamp in a new column within the table?
SELECT ContId
,CreditL
,CreatedOn
FROM dbo.ContactBase
ContId CreditL CreatedOn
1001 NULL2012-05-10 10:12:24.000
1002 NULL2012-05-10 16:10:48.000
1003 NULL2012-05-10 16:16:06.000
1004 NULL2012-05-10 16:25:54.000
1005 NULL2012-05-10 16:29:55.000
August 24, 2012 at 7:14 am
it depends on what you mean by "month", either the number or the name:
there's some handy built in functions to help:
SELECT ContId
,CreditL
,CreatedOn,
MONTH(CreatedOn) As MonthNumber,
DATENAME(month,CreatedOn) As MonthName
FROM dbo.ContactBase
Lowell
August 24, 2012 at 7:21 am
Yes Brilliant thank you!!
ContId CreditL CreatedOn MonthNumber MonthName
1001 NULL 2012-05-10 10:12:24.0005 May
1002 NULL 2012-05-10 16:10:48.0005 May
1003 NULL 2012-05-10 16:16:06.0005 May
1004 NULL 2012-05-10 16:25:54.0005 May
Cheers!
August 24, 2012 at 7:21 am
🙂
Viewing 4 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply