niralibaan
23rd November 2010, 08:05
Hi,
Pls tell me how can i compare two dates (one having utc date type and another having simple date type).
eg:
r.bdate=utc.to.date( tdgil066.dat18, yr,mnth,day,hr,mins,secs)
a=concat$("/",yr,mnth,day)
select bpmdm001.*
from bpmdm001
where bpmdm001.daob >= {:a}
Here "tdgil066.dat18" is of utc date type and "bpmdm001.daob" having simple date type having date in yyyy/mm/dd format.
So i am converting this utc date type to string through
a=concat$("/",yr,mnth,day)
but now i want to compare it with "bpmdm001.daob".
Its giving error at compile time that " 'a' should be of type DATE instead of type STRING"
Pls help.
Regards,
Nirali
sameer.don
23rd November 2010, 08:21
Check the domain of field bpmdm001.daob
Use same domain to declare variable a.
Assuming the domain of the field is "tfgld.date"
ur code should look like:
domain tfgld.date a
r.bdate=utc.to.date( tdgil066.dat18, yr,mnth,day,hr,mins,secs)
date.to.num(a,yr,mnth,day)
select bpmdm001.*
from bpmdm001
where bpmdm001.daob >= {:a}
niralibaan
23rd November 2010, 08:31
Hi Sameer,
Thanks for the code.
I have tried it but it is still giving error:
Error : Illegal argument 4 for function 'date.to.num'
Error: 3 arguments expected for function 'date.to.num'
The domain of "bpmdm001.daob" is "tcntdt". I am declaring vaiable 'a' as 'tcntdt', but at compile time i am facing above mentioned error.
Pls help.
Regards,
Nirali
sameer.don
23rd November 2010, 09:17
check the syntax of funciton date.to.num(a,yr,mnth,day)
it shoud be a = date.to.num(yr,mnth,day)
Syntax: long date.to.num() ( long yearno, long monthno, long month_dayno )
Regards
niralibaan
23rd November 2010, 10:38
Thanks.It works.Now I have another issue.
"bpmdm001.daob" is date having 'tcntdt' domain having format (yyyy/mm/dd). Now I want to extract only mm and dd from this format then how can i do this?
For eg:
bpmdm001.daob having value "2010/12/03" and I want to extract 12 and 03 from it in string format, then how can i do this?
Pls help.
Regards,
Nirali
sameer.don
23rd November 2010, 10:58
Nirali, you have already done that using utc.to.date () function in your code.
Use num.to.date () insetad of utc.to.date().
Syntax: long num.to.date() ( long dayno, ref long yearno, ref long monthno, ref long month_dayno )
niralibaan
23rd November 2010, 13:05
Can u pls send me the code to use num.to.date for fetching month and day from "bpmdm001.daob" field?
bdittmar
23rd November 2010, 20:28
Hi,
Pls tell me how can i compare two dates (one having utc date type and another having simple date type).
eg:
r.bdate=utc.to.date( tdgil066.dat18, yr,mnth,day,hr,mins,secs)
a=concat$("/",yr,mnth,day)
select bpmdm001.*
from bpmdm001
where bpmdm001.daob >= {:a}
Here "tdgil066.dat18" is of utc date type and "bpmdm001.daob" having simple date type having date in yyyy/mm/dd format.
So i am converting this utc date type to string through
a=concat$("/",yr,mnth,day)
but now i want to compare it with "bpmdm001.daob".
Its giving error at compile time that " 'a' should be of type DATE instead of type STRING"
Pls help.
Regards,
Nirali
Hello,
use sprintf$() functions:
Dates
| Suppose date format 002 is: "year/month/day in month"
string result(80)
result = sprintf$("%D002", 727168)
| result contains "1991/12/2"
| Example of substitution symbol %D(format)
string result(80)
result = sprintf$("%D(Date: %02d/%02m/%04Y)", date.num())
| result contains "Date: 12/07/1993"
result = sprintf$("Date: %D(%02d %-20H %04Y)", date.num())
| result contains "Date: 12 June 1993"
UTC dates and times
| Date format 002 is "year/month/day in month"
| Time format 001 is "12 hour format:minutes:seconds AM/PM symbol"
string result(80)
result = sprintf$("%u002 %001", utc.num(), utc.num())
| Result contains "1997/01/01 10:02:53 pm"
string result(80)
result = sprintf$("UTC: %u(%02d/%02m/%04Y) %U(%02h%x%02m%x%025 %a)", utc.num(), utc.num())
| result contains "UTC: 22/07/1997 06:24:53 am"
| provided that for the user's language the time
| separator is ":" and the AM symbol is "am"
| Using a comma after a %u substitution symbol
string result(80)
result = sprintf$("%u001, ,Message text....", utc.now())
| result containts "06-05-15,Message text...."
Regards
sameer.don
24th November 2010, 06:39
Can u pls send me the code to use num.to.date for fetching month and day from "bpmdm001.daob" field?
String str.date(10)
num.to.date(bpmdm001.daob,yr,mnth,day)
str.date = concat$("/",yr,mnth,day)
if u want only month n year,
str.date = concat$("/",mnth,yr)