有关日期的函数

kojiang 2003-01-21 08:41:35
有没有知道某个日期(比如:2003年1月21日)得出该日期是星期几(星期二)的函数,谢谢!?
...全文
31 5 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
  • 打赏
  • 举报
回复
你看一下PB的函数集中我记得有个可以直接得到星期的东东!!!!

好像是.....
boyliulang 2003-01-21
  • 打赏
  • 举报
回复
string ls_week
ls_week = DayName(today())
这样可以得到,不过是英语形式,你需要转换,你写一个函数专门转换
例如:change_week
函数的参数:adt_date
string ls_week
ls_week = DayName(adt_date)
if ls_week = 'Tuesday' then
return '周二'
end if

当然你也可以用daynumber
具体你可以看看pb帮助


kkbgp 2003-01-21
  • 打赏
  • 举报
回复
可以使用daynumber(),至于转换成中文显示那可以参考楼上所做的方式,把你daynumber()获得的返回值作为数组下标
kkbgp 2003-01-21
  • 打赏
  • 举报
回复
Description

Determines the day of the week of a date value and returns the number of the weekday.

Syntax

DayNumber ( date )

Argument Description
date The date value from which you want the number of the day of the week
Return value

Integer. Returns an integer (1-7) representing the day of the week of date. Sunday is day 1, Monday is day 2, and so on. If date is NULL, DayNumber returns NULL.
hzhxxx 2003-01-21
  • 打赏
  • 举报
回复

/**********************************************************/
//name : uf_getchaweek
//Function : 得到中文的星期几
//parm :
// 1. date ad_date : 要计算的日期
//return : 中文的星期几(string type)
//Author : hzh
//date : 2002.10.11
/**********************************************************/

string ls_day[7]

ls_day [ 1 ] = "星期日"
ls_day [ 2 ] = "星期一"
ls_day [ 3 ] = "星期二"
ls_day [ 4 ] = "星期三"
ls_day [ 5 ] = "星期四"
ls_day [ 6 ] = "星期五"
ls_day [ 7 ] = "星期六"

RETURN ls_day [daynumber(ad_date)]

1,108

社区成员

发帖
与我相关
我的任务
社区描述
PowerBuilder 相关问题讨论
社区管理员
  • 基础类社区
  • WorldMobile
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧