我需要数据库中的格式值 [英] I need the values from database which is in format
问题描述
我正在办理考勤系统项目..
我有考勤表将所有员工按照他们的工作日状态,
i有查询`select EmpId, AttenDate,状态来自dbo.Attendance`
它会给我这个
1500011 2014-09-01 00:00:00.000
A
1500011 2014- 09-02 00:00:00.000
A
1500011 2014-09-03 00:00:00.000
A
1500011 2014-09-04 00:00:00.000
A
1500011 2014-09-05 00:00:00.000
A
1500011 2014-09-06 00:00 :00.000
P
1500011 2014-09-07 00:00:00.000
A >
。
。
。
到2014-09-31 00:00:00.000
A
68 2014-08-01 00:00:00.000
A
68 2014-08-02 00:00:00.000
P
68 2014-08-03 00:00:00.000
A
68 2014-09-07 00:00:00.000 A
。
。< br $>
。
到2014-09-31 00:00:00.000
A
现在我想将它打印到excel表格中
有格式
Empid 1
2 3
4 5
6 7
8至31
1500011 AAA
AA
PA
A到A
68 A
AP
....................到A
请建议我??
< blockquote>试试这个..
选择 EmpId + ' ' + convert( varchar ( 50 ),AttenDate, 120 )+ CHAR( 13 )+状态来自 dbo.Attendance
这里 CHAR ( 13 )
for 新行和
convert ( varchar ( 50 ),AttenDate, 120 )
< span class =code-digit> 120 日期格式 转换 AttenDate 成 YYYY-MM-dd格式
认为这对你有帮助。
i am working on attendance system project..
I have attendance table will all the employee according to their working day status,
i have the query `select EmpId,AttenDate,status from dbo.Attendance`
it will give me this
1500011 2014-09-01 00:00:00.000
A
1500011 2014-09-02 00:00:00.000
A
1500011 2014-09-03 00:00:00.000
A
1500011 2014-09-04 00:00:00.000
A
1500011 2014-09-05 00:00:00.000
A
1500011 2014-09-06 00:00:00.000
P
1500011 2014-09-07 00:00:00.000
A
.
.
.
upto 2014-09-31 00:00:00.000
A
68 2014-08-01 00:00:00.000
A
68 2014-08-02 00:00:00.000
P
68 2014-08-03 00:00:00.000
A
68 2014-09-07 00:00:00.000 A
.
.
.
upto 2014-09-31 00:00:00.000
A
Now i want to print it into the excel sheet
with is format
Empid 1
2 3
4 5
6 7
8 upto 31
1500011 A A A
A A
P A
A upto A
68 A
A P
....................upto A
Please suggest me??
Try this..
select EmpId+' '+convert(varchar(50),AttenDate,120)+CHAR(13)+status from dbo.Attendance
here CHAR(13) for the New line and convert(varchar(50),AttenDate,120) 120 for the Date Format to Convert AttenDate into YYYY-MM-dd format
think this'll help you.
这篇关于我需要数据库中的格式值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!