Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase ««12

How to split the date format into month with year? Expand / Collapse
Author
Message
Posted Wednesday, January 1, 2014 8:09 AM


SSC-Insane

SSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-Insane

Group: General Forum Members
Last Login: Today @ 9:09 PM
Points: 20,739, Visits: 32,528
Jeff Moden (12/31/2013)
Lynn Pettis (12/31/2013)
Assuming this is still true: billed_date datetime

right('0' + cast(month(billed_date) as varchar(2)),2) + '-' + cast(year(billed_date) as varchar(4))



... or...

 SELECT RIGHT(CONVERT(CHAR(10),GETDATE(),105),7)




To the OP: And you can learn about COVERT and the different format codes it accepts by reading Books Online as well.

Remember, Books Online can be your friend.



Lynn Pettis

For better assistance in answering your questions, click here
For tips to get better help with Performance Problems, click here
For Running Totals and its variations, click here or when working with partitioned tables
For more about Tally Tables, click here
For more about Cross Tabs and Pivots, click here and here
Managing Transaction Logs

SQL Musings from the Desert Fountain Valley SQL (My Mirror Blog)
Post #1526907
« Prev Topic | Next Topic »

Add to briefcase ««12

Permissions Expand / Collapse