//Query
select CONVERT(date, Tally_VOUCHER.Date), CASE
WHEN DATEPART(MONTH,CONVERT(date, Tally_VOUCHER.Date))=4 then
case when DATEPART(DAY,CONVERT(date, Tally_VOUCHER.Date))<=15 then 1 else 2 end
WHEN DATEPART(MONTH,CONVERT(date, Tally_VOUCHER.Date))=5 then
case when DATEPART(DAY,CONVERT(date, Tally_VOUCHER.Date))<=15 then 3 else 4 end
WHEN DATEPART(MONTH,CONVERT(date, Tally_VOUCHER.Date))=6 then
case when DATEPART(DAY,CONVERT(date, Tally_VOUCHER.Date))<=15 then 5 else 6 end
WHEN DATEPART(MONTH,CONVERT(date, Tally_VOUCHER.Date))=7 then
case when DATEPART(DAY,CONVERT(date, Tally_VOUCHER.Date))<=15 then 7 else 8 end
WHEN DATEPART(MONTH,CONVERT(date, Tally_VOUCHER.Date))=8 then
case when DATEPART(DAY,CONVERT(date, Tally_VOUCHER.Date))<=15 then 9 else 10 end
WHEN DATEPART(MONTH,CONVERT(date, Tally_VOUCHER.Date))=9 then
case when DATEPART(DAY,CONVERT(date, Tally_VOUCHER.Date))<=15 then 11 else 12 end
WHEN DATEPART(MONTH,CONVERT(date, Tally_VOUCHER.Date))=10 then
case when DATEPART(DAY,CONVERT(date, Tally_VOUCHER.Date))<=15 then 13 else 14 end
WHEN DATEPART(MONTH,CONVERT(date, Tally_VOUCHER.Date))=11 then
case when DATEPART(DAY,CONVERT(date, Tally_VOUCHER.Date))<=15 then 15 else 16 end
WHEN DATEPART(MONTH,CONVERT(date, Tally_VOUCHER.Date))=12 then
case when DATEPART(DAY,CONVERT(date, Tally_VOUCHER.Date))<=15 then 17 else 18 end
WHEN DATEPART(MONTH,CONVERT(date, Tally_VOUCHER.Date))=1 then
case when DATEPART(DAY,CONVERT(date, Tally_VOUCHER.Date))<=15 then 19 else 20 end
WHEN DATEPART(MONTH,CONVERT(date, Tally_VOUCHER.Date))=2 then
case when DATEPART(DAY,CONVERT(date, Tally_VOUCHER.Date))<=15 then 21 else 22 end
WHEN DATEPART(MONTH,CONVERT(date, Tally_VOUCHER.Date))=3 then
case when DATEPART(DAY,CONVERT(date, Tally_VOUCHER.Date))<=15 then 23 else 24 end
END Month_Num
from
Tally_VOUCHER
//Result
Dates Month_Num
2013-10-31 14
2013-12-31 18
2013-11-29 16
2013-12-04 17
2013-04-25 2
2013-07-05 7
2013-07-31 8
2013-05-15 3
2013-08-27 10
2013-09-24 12
2013-11-04 15
2013-06-29 6
2013-05-31 4
2013-06-10 5
2013-09-01 11
No comments:
Post a Comment