如何同时使用convert和datepart

时间:2014-08-20 03:49:36

标签: sql-server

我这里有一个选择命令,用于我的水晶报告:

SELECT     cfvgl.v_id, operator.o_id, cfvgl.cfvgl_no, operator.owner_name, 
                      operator.business_address, vessel_details.ship_name, payment.or_number , 
                      payment .date_paid , payment.amount , signature.data, 
                      cfvgl.cfvgl_date_released, DATEPART(day, cfvgl.cfvgl_validity_start) as day_issued, 
                      DATEPART(month, cfvgl.cfvgl_validity_start) as month_issued, 
                      DATEPART(year, cfvgl.cfvgl_validity_start) as year,
                      gear.bag_bunt_mesh_size, gear.body_mesh_size, gear.wing_mesh_size,
                      cfvgl.catcher_type, cfvgl.other_gear, gear.stretched_depth, 
                      gear.finished_depth, gear.mesh_size, gear.finished_length, 
                      gear.finished_width, gear.total_length, gear.cod_end_mesh_size,
                      gear.otter_board_size, gear.towing_rope_length, gear.tomweight, 
                      gear.bouyline_length, gear.branchline_length, gear.branchline_distance, 
                      gear.hook_number, gear.hook_type, gear.hook_size, gear.bait_type, 
                      gear.hook_total_number, gear.target_species, gear.mainline_length, 
                      gear.swivel_size, gear.wire_leader_length, gear.netting_type
FROM         cfvgl  INNER JOIN
                      vessel_details ON vessel_details.v_id = cfvgl.v_id INNER JOIN
                      operator ON vessel_details.o_id = operator.o_id LEFT OUTER JOIN
                      applications ON vessel_details.v_id = applications.v_id LEFT OUTER JOIN
                      payment ON payment.app_no = applications.app_no LEFT OUTER JOIN
                      gear ON gear.v_id = vessel_details.v_id LEFT OUTER JOIN
                      signature ON signature.signature_id = cfvgl.signature_id

我的问题是,我必须转换并显示datepart(月)的返回日期作为单词,例如1 = 1月..

我只在这个月的日期,

DATEPART(month, cfvgl.cfvgl_validity_start) as month_issued

我如何才能将datepart月份的格式更改为单词?

感谢。

2 个答案:

答案 0 :(得分:1)

使用DATENAME获取名称。

DATENAME(month, cfvgl.cfvgl_validity_start) as month_issued

答案 1 :(得分:1)

使用DATENAME函数以这样的字词获取月份:

SELECT DATENAME(month, cfvgl.cfvgl_validity_start) AS month_issued
FROM yourtable