Quantcast
Channel: SCN : Unanswered Discussions - Reporting and Printing
Viewing all articles
Browse latest Browse all 776

SQL Query how to combine two fields Year and Month to one field Period

$
0
0

Hello,

 

I have the following Query:

 

SELECT t0.[Docnum], t0.[docdate],  (Datepart(Year,T0.[DocDate])) , (Datepart(Month,T0.[DocDate])), t0.[doctotal] FROM OINV T0 where t0.[docdate] >= '20140101'

 

This results in a list of AR/Invoices with Docnum, Docdate, Year, Month, Doctotal in a separate columns.

 

I would like to combine the two columns "Year" and "Month" in one column "Period" which is written as follows:

 

2014-01

2014-02

.....

2014-09

2014-10

2014-11

2014-12

2015-01

 

The zero at the months lower than 10 is essential because of sorting issues.

 

what statement do i have to use to realise this ?

 

Who can help me with this ? - Thanks in advance


Viewing all articles
Browse latest Browse all 776

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>