Author |
Message
|
brgmo |
Posted: Mon Oct 29, 2007 4:22 am Post subject: Date format |
|
|
Master
Joined: 03 Jun 2002 Posts: 227
|
Hi All,
Can someone please help me in getting the followinf format of date:
2007/10/30
How to get the date in the above format. I have explored the date function and it doesn't work the way i want.
Also, what should i do get only </fieldname> in the output i mean i don't want to have <fieldname></fieldname> but instead only the closing tag i.e. </fieldname>.
Regards
brgmo. |
|
Back to top |
|
 |
jefflowrey |
Posted: Mon Oct 29, 2007 4:30 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
A) date formatting depends on what domain you are using.
b) how XML is rendered depends on what XML domain you are using, but generally to get the result you want, the element must exist in the tree, but have no value. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
brgmo |
Posted: Mon Oct 29, 2007 4:36 am Post subject: |
|
|
Master
Joined: 03 Jun 2002 Posts: 227
|
Thanks Jeff. I am using XML domain presently but will be MRM later on.
For getting the desired date pattern i have written the following code:
declare pattern char 'yyyy/dd/mm'
set outputroot.xml.dat = cast(current_date as date format pattern)
for getting xml with the closing tag only, i have written the following code:
set outputroot.xml.notag value null;
both of the above are notworking.
Regards
brgmo. |
|
Back to top |
|
 |
jefflowrey |
Posted: Mon Oct 29, 2007 4:38 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
Why would you possibly use XML, when you should be using XMLNS or XMLNSC?
Casting a date field into a date field won't cause any formatting to occur. The FORMAT clause is for controlling how a string value is turned into a date field, or a date field is turned into a string field.
Remember that XML data is all strings, anyway. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
jefflowrey |
Posted: Mon Oct 29, 2007 4:39 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
Also, setting the value of a non-existent field won't create the field, afaik. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
brgmo |
Posted: Mon Oct 29, 2007 5:16 am Post subject: |
|
|
Master
Joined: 03 Jun 2002 Posts: 227
|
Please,anyone can helpme on this.
Regards
brgmo. |
|
Back to top |
|
 |
jefflowrey |
Posted: Mon Oct 29, 2007 5:24 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
Don't use XML. Use XMLNS or XMLNSC. Really!
Cast your date value to a CHARACTER, rather than another date.
create or set the noData field in output first, and then set the value to NULL. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
vsr |
Posted: Mon Oct 29, 2007 5:32 am Post subject: |
|
|
Centurion
Joined: 04 Apr 2006 Posts: 104
|
1)CAST(CURRENT_DATE AS CHARACTER FORMAT 'yyyy/DD/mm')
2)CREATE FIELD OutputRoot.XMLNS.<Root_Tag>.notag VALUE(NULL); |
|
Back to top |
|
 |
brgmo |
Posted: Mon Oct 29, 2007 6:18 am Post subject: |
|
|
Master
Joined: 03 Jun 2002 Posts: 227
|
CAST(CURRENT_DATE AS CHARACTER FORMAT 'yyyy/DD/mm')
the above code doesn't work and displays just //00. any idea. |
|
Back to top |
|
 |
vsr |
Posted: Mon Oct 29, 2007 9:15 am Post subject: |
|
|
Centurion
Joined: 04 Apr 2006 Posts: 104
|
Try this:
CAST(CURRENT_DATE AS CHARACTER FORMAT 'yyyy/dd/MM') |
|
Back to top |
|
 |
|