--
------------------------------------------------------------------------
--
Author : 原著: 改编:htl258(Tony)
--
Date : 2010-04-24 06:39:55
--
Version:Microsoft SQL Server 2008 (RTM) - 10.0.1600.22 (Intel X86)
--
Jul 9 2008 14:43:34
--
Copyright (c) 1988-2008 Microsoft Corporation
--
Developer Edition on Windows NT 5.1 <X86> (Build 2600: Service Pack 3)
--
Blog : http://blog.csdn.net/htl258
--
Subject: 完善SQL农历转换函数(显示中文格式,加入润月的显示)
--
------------------------------------------------------------------------
--
注:由于找一时找不到原版作者,所以暂未填入。大家有知道的告知一下,谢谢!
--
创建基础数据表
if
object_id
(
'
SolarData
'
)
is
not
null
drop
table
SolarData
go
create
table
SolarData
(
yearid
int
not
null
,
data
char
(
7
)
not
null
,
dataint
int
not
null
)
--
插入数据
insert
into
SolarData
select
1900
,
'
0x04bd8
'
,
19416
union
all
select
1901
,
'
0x04ae0
'
,
19168
union
all
select
1902
,
'
0x0a570
'
,
42352
union
all
select
1903
,
'
0x054d5
'
,
21717
union
all
select
1904
,
'
0x0d260
'
,
53856
union
all
select
1905
,
'
0x0d950
'
,
55632
union
all
select
1906
,
'
0x16554
'
,
91476
union
all
select
1907
,
'
0x056a0
'
,
22176
union
all
select
1908
,
'
0x09ad0
'
,
39632
union
all
select
1909
,
'
0x055d2
'
,
21970
union
all
select
1910
,
'
0x04ae0
'
,
19168
union
all
select
1911
,
'
0x0a5b6
'
,
42422
union
all
select
1912
,
'
0x0a4d0
'
,
42192
union
all
select
1913
,
'
0x0d250
'
,
53840
union
all
select
1914
,
'
0x1d255
'
,
119381
union
all
select
1915
,
'
0x0b540
'
,
46400
union
all
select
1916
,
'
0x0d6a0
'
,
54944
union
all
select
1917
,
'
0x0ada2
'
,
44450
union
all
select
1918
,
'
0x095b0
'
,
38320
union
all
select
1919
,
'
0x14977
'
,
84343
union
all
select
1920
,
'
0x04970
'
,
18800
union
all
select
1921
,
'
0x0a4b0
'
,
42160
union
all
select
1922
,
'
0x0b4b5
'
,
46261
union
all
select
1923
,
'
0x06a50
'
,
27216
union
all
select
1924
,
'
0x06d40
'
,
27968
union
all
select
1925
,
'
0x1ab54
'
,
109396
union
all
select
1926
,
'
0x02b60
'
,
11104
union
all
select
1927
,
'
0x09570
'
,
38256
union
all
select
1928
,
'
0x052f2
'
,
21234
union
all
select
1929
,
'
0x04970
'
,
18800
union
all
select
1930
,
'
0x06566
'
,
25958
union
all
select
1931
,
'
0x0d4a0
'
,
54432
union
all
select
1932
,
'
0x0ea50
'
,
59984
union
all
select
1933
,
'
0x06e95
'
,
28309
union
all
select
1934
,
'
0x05ad0
'
,
23248
union
all
select
1935
,
'
0x02b60
'
,
11104
union
all
select
1936
,
'
0x186e3
'
,
100067
union
all
select
1937
,
'
0x092e0
'
,
37600
union
all
select
1938
,
'
0x1c8d7
'
,
116951
union
all
select
1939
,
'
0x0c950
'
,
51536
union
all
select
1940
,
'
0x0d4a0
'
,
54432
union
all
select
1941
,
'
0x1d8a6
'
,
120998
union
all
select
1942
,
'
0x0b550
'
,
46416
union
all
select
1943
,
'
0x056a0
'
,
22176
union
all
select
1944
,
'
0x1a5b4
'
,
107956
union
all
select
1945
,
'
0x025d0
'
,
9680
union
all
select
1946
,
'
0x092d0
'
,
37584
union
all
select
1947
,
'
0x0d2b2
'
,
53938
union
all
select
1948
,
'
0x0a950
'
,
43344
union
all
select
1949
,
'
0x0b557
'
,
46423
union
all
select
1950
,
'
0x06ca0
'
,
27808
union
all
select
1951
,
'
0x0b550
'
,
46416
union
all
select
1952
,
'
0x15355
'
,
86869
union
all
select
1953
,
'
0x04da0
'
,
19872
union
all
select
1954
,
'
0x0a5d0
'
,
42448
union
all
select
1955
,
'
0x14573
'
,
83315
union
all
select
1956
,
'
0x052d0
'
,
21200
union
all
select
1957
,
'
0x0a9a8
'
,
43432
union
all
select
1958
,
'
0x0e950
'
,
59728
union
all
select
1959
,
'
0x06aa0
'
,
27296
union
all
select
1960
,
'
0x0aea6
'
,
44710
union
all
select
1961
,
'
0x0ab50
'
,
43856
union
all
select
1962
,
'
0x04b60
'
,
19296
union
all
select
1963
,
'
0x0aae4
'
,
43748
union
all
select
1964
,
'
0x0a570
'
,
42352
union
all
select
1965
,
'
0x05260
'
,
21088
union
all
select
1966
,
'
0x0f263
'
,
62051
union
all
select
1967
,
'
0x0d950
'
,
55632
union
all
select
1968
,
'
0x05b57
'
,
23383
union
all
select
1969
,
'
0x056a0
'
,
22176
union
all
select
1970
,
'
0x096d0
'
,
38608
union
all
select
1971
,
'
0x04dd5
'
,
19925
union
all
select
1972
,
'
0x04ad0
'
,
19152
union
all
select
1973
,
'
0x0a4d0
'
,
42192
union
all
select
1974
,
'
0x0d4d4
'
,
54484
union
all
select
1975
,
'
0x0d250
'
,
53840
union
all
select
1976
,
'
0x0d558
'
,
54616
union
all
select
1977
,
'
0x0b540
'
,
46400
union
all
select
1978
,
'
0x0b5a0
'
,
46496
union
all
select
1979
,
'
0x195a6
'
,
103846
union
all
select
1980
,
'
0x095b0
'
,
38320
union
all
select
1981
,
'
0x049b0
'
,
18864
union
all
select
1982
,
'
0x0a974
'
,
43380
union
all
select
1983
,
'
0x0a4b0
'
,
42160
union
all
select
1984
,
'
0x0b27a
'
,
45690
union
all
select
1985
,
'
0x06a50
'
,
27216
union
all
select
1986
,
'
0x06d40
'
,
27968
union
all
select
1987
,
'
0x0af46
'
,
44870
union
all
select
1988
,
'
0x0ab60
'
,
43872
union
all
select
1989
,
'
0x09570
'
,
38256
union
all
select
1990
,
'
0x04af5
'
,
19189
union
all
select
1991
,
'
0x04970
'
,
18800
union
all
select
1992
,
'
0x064b0
'
,
25776
union
all
select
1993
,
'
0x074a3
'
,
29859
union
all
select
1994
,
'
0x0ea50
'
,
59984
union
all
select
1995
,
'
0x06b58
'
,
27480
union
all
select
1996
,
'
0x055c0
'
,
21952
union
all
select
1997
,
'
0x0ab60
'
,
43872
union
all
select
1998
,
'
0x096d5
'
,
font-weight
分享到:
相关推荐
### SQL简繁转换函数 在处理多语言环境下的数据时,简繁体转换是一个非常重要的功能,尤其是在中文环境中。本文将详细介绍如何在SQL Server数据库中实现简繁体转换,并通过一个具体的示例来演示如何创建并使用简繁...
29.完善SQL农历转换函数 50 30.自定义函数实现位操作 58 31.求某段时间内星期几的天数 61 32.根据进舍位或四舍五入来求值 63 33.字符串转成16进制函数 64 34.去掉字段中多个带区号电话号码前面的区号 65 35.SQL2000/...
根据提供的文件信息,本文将详细解析如何在SQL中创建农历函数。这涉及到农历日期与公历日期之间的转换问题,以及如何在数据库环境中实现这一功能。 ### 一、创建农历数据表 首先,从部分代码来看,它定义了一个名...
总的来说,这个"拼音和五笔码转换函数"提供了一种方便的方式来处理汉字与拼音、五笔码之间的转换,对于需要处理汉字编码问题的SQL Server用户来说,是一个非常实用的工具。在数据库开发、数据处理、信息检索等领域,...
为了更好地控制日期的显示格式,SQL Server提供了`CONVERT`函数,它可以将日期转换成指定的格式。下面是一些常见的日期格式代码及其对应的显示效果: - **格式代码000**:表示为“MM/dd/yyyy”,例如“09/14/2001”...
### SQL 日期格式化函数大全 在SQL中,对日期进行格式化是非常常见的需求之一,尤其是在需要将日期数据展示给用户或与其他系统交互时。本文将详细介绍SQL Server中`CONVERT`函数的不同格式代码及其产生的效果,帮助...
在SQL数据库操作中,有时我们需要将日期字段以中文大写的形式展示,这在报表制作、数据分析或者用户界面显示时尤其有用。本篇文章将详细介绍三种在SQL中实现这一功能的方法,包括两种函数方法和一种存储过程方法。 ...
可以将sql server的函数 视图 存储过程等转换为mysql的格式,也可以转其他,很好用的一个sql转换工具,
本文将深入探讨一种特定的SQL脚本函数——十进制数转换为十六进制数的功能,这一过程对于处理数据、加密解密以及色彩代码等领域尤为重要。 ### SQL脚本函数:十进制转十六进制 #### 函数定义 SQL脚本函数`[dbo]....
### SQL脚本函数:16进制转换为10进制 #### 背景介绍 在数据库管理和软件开发过程中,经常需要处理不同进制之间的数值转换问题。尤其是在处理网络协议、加密算法或是数据存储格式时,十六进制与十进制之间的转换...
本文将详细介绍一个在SQL Server中实现的将汉字转换成全拼形式的函数——`fn_GetQuanPin`。 #### 函数概述 此函数名为`[dbo].[fn_GetQuanPin]`,它接收一个长度不超过100个字符的字符串作为输入,并返回一个最大...
PL/SQL 常用函数 PL/SQL 中的函数可以分为两大类:单行函数和组函数。单行函数用于处理单行数据,可以在 SELECT、WHERE、ORDER BY 等子句中使用。今天我们将讨论单行函数的使用和规则。 1. 日期格式转换函数 TO_...
根据给定的信息,本文将详细解释“SQL脚本函数 36进制转换为10进制”的实现原理与具体步骤。此SQL脚本函数的主要功能是将36进制数值转换为十进制数值。 ### 一、理解36进制 在计算机科学中,我们通常使用的是十...
在SQL Server中,时间函数是数据库管理中不可或缺的一部分,它们用于处理和操作日期和时间数据。日期和时间处理在各种业务场景中极为重要,比如数据分析、报表生成、日志记录等。下面我们将深入探讨SQL Server中的...
- `style`:可选参数,用于指定日期时间的显示格式。`style`是一个整数,不同的数值代表不同的日期时间格式。 ### 示例代码解析 在提供的部分代码中,`CONVERT`函数被用来将当前系统日期(通过`GETDATE()`函数获取...
SQL 语言中有多种类型的函数,可以按照不同的分类方式来分类,下面将从函数类别、聚合函数、转换函数、加密函数、游标函数、日期和时间函数、数学函数、元数据函数、排名函数、行集函数、安全函数、字符串函数、系统...
样式编号决定了日期时间的显示格式。以下是部分常用的样式: 1. **Style 0**: MMDDYYYYHH:MI:SS - 示例:`0516200610:57AM` 2. **Style 1**: MM/DD/YY - 示例:`05/16/06` 3. **Style 2**: DD.MM.YY - 示例:`...
### SQL Server 用户自定义函数详解 #### 一、概述 在SQL Server中,用户自定义函数(User-Defined Functions, UDFs)允许开发者创建能够执行特定任务并返回结果的自定义逻辑。这些函数不仅可以增强SQL Server的功能...
使用 `CONVERT` 函数可以改变日期的显示格式。这对于数据展示和导出非常重要。 ```sql CONVERT(varchar, getdate(), style) ``` 其中 `style` 参数定义了日期的显示格式。例如,将其转换为“年-月-日”格式: ```...
Sql Server 中利用Convert 函数转换日期格式,请使用者通读。