ASP中时间格式的转换
2007-03-30 18:51
344 查看
ASP中,读取数据库时时间的格式为:yyyy-mm-dd ,但当月份或日期是一位数时,显示的是:yyyy-m-d ,如:2007-3-1
现在把它转换为2007-03-01的格式
N_date=Rs("N_date")
N_year=year(N_date)
N_month=month(N_date)
N_day=day(N_date)
if len(N_month)=1 then
N_month=0&N_month
end if
if len(N_day)=1 then
N_day=0&N_day
end if
N_date1=N_year&"-"&N_month&"-"&N_day
response.write N_date1
//这个是我自己写的
下面这个是网上搜来的函数
function getdatestr(s)
getdatestr=""
if dstr="" or not isdate(s) then
exit function
end if
dim y,m,d
y=year(s)
m=month(s)
d=day(s)
if m<10 then m="0"&m
if d<10 then d="0"&d
getdatestr=y&"-"&m&"-"&d
end function
调用函数
response.Write(getdatestr(rs("newstime")))
现在把它转换为2007-03-01的格式
N_date=Rs("N_date")
N_year=year(N_date)
N_month=month(N_date)
N_day=day(N_date)
if len(N_month)=1 then
N_month=0&N_month
end if
if len(N_day)=1 then
N_day=0&N_day
end if
N_date1=N_year&"-"&N_month&"-"&N_day
response.write N_date1
//这个是我自己写的
下面这个是网上搜来的函数
function getdatestr(s)
getdatestr=""
if dstr="" or not isdate(s) then
exit function
end if
dim y,m,d
y=year(s)
m=month(s)
d=day(s)
if m<10 then m="0"&m
if d<10 then d="0"&d
getdatestr=y&"-"&m&"-"&d
end function
调用函数
response.Write(getdatestr(rs("newstime")))
相关文章推荐
- ASP.NET C# 日期时间年月日时分秒格式及转换
- ASP.NET:C#中时间格式的转换
- Asp.Net时间格式转换实用方法
- ASP.NET中时间格式的转换
- ASP.NET 日期 时间 年 月 日 时 分 秒 格式及转换
- 时间格式转换ASP.NET
- ASP.NET:C#中时间格式的转换
- ASP.NET C# 日期 时间 年 月 日 时 分 秒 格式及转换
- DateTime.ToString()方法的参数谈ASP.NET中时间格式的转换
- ASP.NET C# 日期 时间 年 月 日 时 分 秒 格式及转换(转自happymagic的专栏)
- ASP.NET:C#中时间格式的转换
- ASP.NET 日期 时间 年 月 日 时 分 秒 格式及转换
- ASP.NET C# 日期 时间 年 月 日 时 分 秒 格式及转换
- C#,Asp.NET 导入Excel,时间格式一串数字转换.
- ASP.NET:C#中时间格式的转换
- 将时间转换成固定格式
- j2me中如何使用Calendar获取系统时间并转换成字符串格式
- JavaScript 格式化日期,转换时间日期格式
- mysql 时间转换 用EXCEL实现MySQL时间戳格式和日期格互转
- java部分基础类型及时间格式的数据格式相互转换方法整理