สวัสดีครับ
function return อายุเป็นปีเดือนวันจากวันเกิดและวันที่ต้องการคำนวนโดยอาศัย function ของ SQL เลยฝากมาให้ดูครับ
argument มี 2 ตัว คือ ad_birth = วันเกิด, ad_now = วันที่ต้องการคำนวน
import script ต่อไปนี้ได้เลยครับ
$PBExportHeader$f_age_string.srf
global type f_age_string from function_object
end type
forward prototypes
global function string f_age_string (datetime ad_birth, datetime ad_now)
end prototypes
global function string f_age_string (datetime ad_birth, datetime ad_now);
long ll_year, ll_month, ll_day
string ls_return
SELECT datediff( day, :ad_birth, :ad_now ) INTO :ll_day from anes_itemtype ;
SELECT datediff( month, :ad_birth, :ad_now ) INTO :ll_month from anes_itemtype ;
SELECT datediff( year, :ad_birth, :ad_now ) INTO :ll_year from anes_itemtype ;
if ll_year > 0 then ls_return = string(ll_year) + ' ปี '
if ll_year < 3 then
if ll_month > 0 then ls_return = ls_return + string(ll_month) + ' เดือน '
end if
if ll_year = 0 and ll_month = 0 then ls_return = string(ll_day) + ' วัน '
return ls_return
end function
anes_itemtype เป็นชื่อ table อะไรก็ได้ที่มีอยู่ และมี record อย่างน้อย 1 record มิฉนั้นจะไม่ return ค่ากลับมา
สำหรับฟังก์ชั่นนี้ก็ต้องขอขอบคุณ คุณ 3P มากครับที่เอื้อเฟื้อ จัดส่งมาให้ครับ
บทความนี้มาจาก www.soopawat.com
function หาอายุเป็นปีเดือนวันจากวันเกิดกับวันที่ต้องการ
Latest News
- บทที่ 7-1 ตอน การสร้างระบบฐานข้อมูล
- บทที่ 6 ทดลองเขียนโปรแกรมด้วย PocketBuilder เบื้องต้น
- บทที่ 4 ติดตั้งdatabase sql anywhere
- บทที่ 7-2 ตอน การสร้างโปรแกรมแสดงรายการอาหารที่สั่ง ด้วย Powerbuilder 9
- บทที่ 3 ติดตั้งอุปกรณ์ และโปรแกรม Active Sync
- ทำชุด setup โปรแกรมด้วย Wise Install
- การติดตั้ง IIS
- ตัวอย่าง code โปรแกรมร้านเช่า VDO
- สมาชิก : 2
- Content : 336
- เว็บลิงก์ : 8
- จำนวนครั้งเปิดดูบทความ : 159024


