stecorp
17th April 2013, 13:32
I am trying to convert the UTC number to date that I received from the form field to get the month.
Domain form field :
extern domain cpcom.date i.pdat.t
It is acually the UTC date
When I run the session in debug mode I am getting the value "1367334000"
How can I get the month from the above number from the form field.
when I try the following statement, the value for the date.nu() is half of the digits of i.pdat.t and it is getting the month in the variable sm.
date.ret = num.to.date(date.num(), sy, sm, sd)
When I try the following, then it is not getting the month.
date.ret = num.to.date(i.pdat.t, sy, sm, sd)
Any other way to get the UTC number to date?
Any support in this regard will be great help.
bdittmar
17th April 2013, 14:00
I am trying to convert the UTC number to date that I received from the form field to get the month.
Domain form field :
extern domain cpcom.date i.pdat.t
It is acually the UTC date
When I run the session in debug mode I am getting the value "1367334000"
How can I get the month from the above number from the form field.
when I try the following statement, the value for the date.nu() is half of the digits of i.pdat.t and it is getting the month in the variable sm.
date.ret = num.to.date(date.num(), sy, sm, sd)
When I try the following, then it is not getting the month.
date.ret = num.to.date(i.pdat.t, sy, sm, sd)
Any other way to get the UTC number to date?
Any support in this regard will be great help.
Hello,
use sprintf$() :
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...."
-------------------------------
For utc dates:
you can use something like :
extern domain tcyrno year
extern domain tcweek week
extern domain tcmnth month
function prepare.date.data(domain tctrns.date whinh431.iadt)
{
year = val(sprintf$("%u(%04Y)",whinh431.iadt))
week = val(sprintf$("%u(%02W)",whinh431.iadt))
month = val(sprintf$("%u(%02m)",whinh431.iadt))
}
Regards
Juergen
18th April 2013, 10:08
Hi,
you can also use function utc.to.date
Example:
long year, month, day, hours, minutes, seconds
utc.to.date(i.pdat.t, year, month, day, hours, minutes, seconds)
Rgds,
Juergen
stecorp
19th April 2013, 13:50
Hi Bernd and Juergen,
Thank you very much for the suggestions.
Since I need only the month from the user selection, I used utc.to.date for my purpose.
regards,
Stephen