SQLServer 中处理两个日期相减得到天数
DATEDIFF(datepart, startdate, enddate)
Datepart Abbreviations
year yy, yyyy
quarter qq, q
month mm, m
dayofyear dy, y
day dd, d
week wk, ww
hour hh
minute mi, n
second ss, s
millisecond ms
相关文档:
今天在写视图时,遇到要把Datetime类型转Varchar类型。以前在ORALCE就容易,直接ToChar(getdate(),'yyyy-mm-dd')。在SQL Server 2005
select CONVERT(varchar, getdate(), 120 )
2004-09-12 11:06:08
select CONVERT(varchar(12) , getdate(), 111 )
2004/09/12
select CONVERT(varchar(12) , getdate(), 112 )
200 ......
create database DB
use DB
--专业表
create table major
(spno char(5) not null primary key,
spname varchar(20) not null,
pno char(2) )
--学生表
create table student
(sno char(7) not null primary key,
sname varchar(20) not null,
ssex char(2) not null,
sag ......
import pymssql
#connect database
conn=pymssql.connect(host="192.168.1.28",user="boomink",password="boomink",
database="boomink")
cur=conn.cursor()
print '========================================'
cur.execute("exec Orders_GetTest1 @Valu ......
/*drop table scourse
drop table course
drop table student
drop table major*/
create database db
use db
--专业表
create table major
(spno char(5) not null primary key,
spname varchar(20) not null,
pno char(2) )
--学生表
create table student
(sno char(7) not null primary key,
......
字符串函数:
● ASCII('a')=97---返回字母a对应的ASCII码
● CHAR('48')=0---返回48这个ASCII码对应的字符
● LCASE('ABcdE')="abced" 或 LOWER('ABcdE')="abced"(将给定字符串转为小写)
● UCASE('ABcdE')="ABCDE" 或 UPPER('ABcdE')="ABCDE"(将给定字符串转为大写)
● LTRIM(' fgf gh ')="fgf ......