Editing portions of DATE field to compose a date value2019 Community Moderator ElectionHow to return only the Date from a SQL Server DateTime datatypeCompare two dates with JavaScriptAdd days to JavaScript DateWhere can I find documentation on formatting a date in JavaScript?Detecting an “invalid date” Date instance in JavaScriptHow do I get the current date in JavaScript?Calculate difference between two dates (number of days)?How to format a JavaScript dateGet current time and date on AndroidConvert string of length 8 to *EUR date for comparing
Do I need life insurance if I can cover my own funeral costs?
How to make healing in an exploration game interesting
Does this AnyDice function accurately calculate the number of ogres you make unconcious with three 4th-level castings of Sleep?
PTIJ: Who should pay for Uber rides: the child or the parent?
The use of "touch" and "touch on" in context
What has been your most complicated TikZ drawing?
Why must traveling waves have the same amplitude to form a standing wave?
How to deal with taxi scam when on vacation?
How do anti-virus programs start at Windows boot?
Did CPM support custom hardware using device drivers?
Dot in front of file
Replacing Windows 7 security updates with anti-virus?
Official degrees of earth’s rotation per day
What is this large pipe coming out of my roof?
Is a lawful good "antagonist" effective?
Current sense amp + op-amp buffer + ADC: Measuring down to 0 with single supply
Using "wallow" verb with object
Good allowance savings plan?
What is IP squat space
Can anyone tell me why this program fails?
Instead of Universal Basic Income, why not Universal Basic NEEDS?
What are the possible solutions of the given equation?
Possible Leak In Concrete
Why do passenger jet manufacturers design their planes with stall prevention systems?
Editing portions of DATE field to compose a date value
2019 Community Moderator ElectionHow to return only the Date from a SQL Server DateTime datatypeCompare two dates with JavaScriptAdd days to JavaScript DateWhere can I find documentation on formatting a date in JavaScript?Detecting an “invalid date” Date instance in JavaScriptHow do I get the current date in JavaScript?Calculate difference between two dates (number of days)?How to format a JavaScript dateGet current time and date on AndroidConvert string of length 8 to *EUR date for comparing
When using RPGLE's %date()
function I can "converte" a string displaying a date like '2019-01-01'
via %date('2019-01-01':*ISO)
or '20190202'
via %date('20190202':*ISO0)
into a date field.
dcl-s dateISO date(*ISO);
dateISO = %date('2019-01-01':*ISO);
dsply dateISO;
dateISO = %date('20190202':*ISO0);
dsply dateISO;
On my current database date values are split up into 3 (sometimes 4) different fields rather than stored in fields defined as 'date': On for the day part, one for the month and 1 or 2 (depends on the age of the database file) fields for either the year as 4 digit or one field for the 2 digit century and one for the 2 digit year (2019 -> stored as '2019' or '20' and '19')
In my beginning, I leard to group the 3 zoned date fields with a data structure and use the overlaying "date-subfield" for my DDS
(DSPF/PRTF
) or "working with dates".
I "discovered" for myself the beauty of DATE fields and that I can use the %date()
BIF to convert the data structure subfield, which represents the full date, to my needed date field. But for reasons, I don't want to create a new data structure for each "new" date.
So like using %subdt()
for extracting portions of a DATE or TIMESTAMP I hoped that I can edit a portion of a DATE field.
Does anyone know how to do it?
Edit:
To all those who thougt I want to GET a portion of a date: NO, I just want to EDIT (as written in the headline) a portion of the date. Like I have a DDS PF definition like this:
A R TESTPFR
A
A T1NUMB 6S 0 TEXT('Some number')
A T1TEXT 10A TEXT('Some text')
A T1DTDD 2S 0 TEXT('Day part')
A T1DTMM 2S 0 TEXT('Month part')
A T1DTYY 4S 0 TEXT('Year part')
My "old" way was like this:
**free
ctl-opt decedit('0,') datedit(*dmy) dftactgrp(*no) option(*nodebugio:*srcstmt:*nounref);
dcl-f testpf disk; // Database File
dcl-ds dateDS qualified; // DS for "converting"
date zoned(8) pos(1);
day zoned(2) pos(1);
month zoned(2) pos(3);
year zoned(4) pos(5);
end-ds;
dcl-s dateISO date(*ISO); // Destination Date field
dcl-ds testpfrDS likerec(testpfr); // Record definition if the database file
read testpfr testpfrDS;
dow (not %eof(testpf));
dateDS.day = testpfrDS.t1dtdd ; //t1dtdd is the day field
dateDs.month = testpfrDS.t1dtmm; //t1dtdd is the month field
dateDs.year = testpfrDS.t1dtyy; //t1dtdd is the year field
dateISO = %date(dateDS.date:*EUR);
dsply dateISO; // Work with the date
read testpfr testpfrDS;
enddo;
*inlr = *on;
This ment that I had to define a data structure in each new program, put the PF fields into the subfields and convert the overlaying subfield. In this case this was not that much overhead. But when having DSPF involved where the use input a range of date, I had to write a DS for the FROM date, the TO date and the date from the database. Ok I admit that I could make it like above, just make one DS and use this for the three dates. But my hope was that I can just define a date field and code someting like this:
%subdt(dateISO:*day) = testpfrDS.t1dtdd;
%subdt(dateISO:*month) = testpfrDS.t1dtmm;
%subdt(dateISO:*year) = testpfrDS.t1dtyy;
So I don't have to built a DS for the date conversion every time.
But as @jmarkmurphy answered, I now came up with the solution of having a DS with the three/four date subfields and one overlaying subfield which is defined as DATE, so I dnon't have to use %date()
date rpgle
add a comment |
When using RPGLE's %date()
function I can "converte" a string displaying a date like '2019-01-01'
via %date('2019-01-01':*ISO)
or '20190202'
via %date('20190202':*ISO0)
into a date field.
dcl-s dateISO date(*ISO);
dateISO = %date('2019-01-01':*ISO);
dsply dateISO;
dateISO = %date('20190202':*ISO0);
dsply dateISO;
On my current database date values are split up into 3 (sometimes 4) different fields rather than stored in fields defined as 'date': On for the day part, one for the month and 1 or 2 (depends on the age of the database file) fields for either the year as 4 digit or one field for the 2 digit century and one for the 2 digit year (2019 -> stored as '2019' or '20' and '19')
In my beginning, I leard to group the 3 zoned date fields with a data structure and use the overlaying "date-subfield" for my DDS
(DSPF/PRTF
) or "working with dates".
I "discovered" for myself the beauty of DATE fields and that I can use the %date()
BIF to convert the data structure subfield, which represents the full date, to my needed date field. But for reasons, I don't want to create a new data structure for each "new" date.
So like using %subdt()
for extracting portions of a DATE or TIMESTAMP I hoped that I can edit a portion of a DATE field.
Does anyone know how to do it?
Edit:
To all those who thougt I want to GET a portion of a date: NO, I just want to EDIT (as written in the headline) a portion of the date. Like I have a DDS PF definition like this:
A R TESTPFR
A
A T1NUMB 6S 0 TEXT('Some number')
A T1TEXT 10A TEXT('Some text')
A T1DTDD 2S 0 TEXT('Day part')
A T1DTMM 2S 0 TEXT('Month part')
A T1DTYY 4S 0 TEXT('Year part')
My "old" way was like this:
**free
ctl-opt decedit('0,') datedit(*dmy) dftactgrp(*no) option(*nodebugio:*srcstmt:*nounref);
dcl-f testpf disk; // Database File
dcl-ds dateDS qualified; // DS for "converting"
date zoned(8) pos(1);
day zoned(2) pos(1);
month zoned(2) pos(3);
year zoned(4) pos(5);
end-ds;
dcl-s dateISO date(*ISO); // Destination Date field
dcl-ds testpfrDS likerec(testpfr); // Record definition if the database file
read testpfr testpfrDS;
dow (not %eof(testpf));
dateDS.day = testpfrDS.t1dtdd ; //t1dtdd is the day field
dateDs.month = testpfrDS.t1dtmm; //t1dtdd is the month field
dateDs.year = testpfrDS.t1dtyy; //t1dtdd is the year field
dateISO = %date(dateDS.date:*EUR);
dsply dateISO; // Work with the date
read testpfr testpfrDS;
enddo;
*inlr = *on;
This ment that I had to define a data structure in each new program, put the PF fields into the subfields and convert the overlaying subfield. In this case this was not that much overhead. But when having DSPF involved where the use input a range of date, I had to write a DS for the FROM date, the TO date and the date from the database. Ok I admit that I could make it like above, just make one DS and use this for the three dates. But my hope was that I can just define a date field and code someting like this:
%subdt(dateISO:*day) = testpfrDS.t1dtdd;
%subdt(dateISO:*month) = testpfrDS.t1dtmm;
%subdt(dateISO:*year) = testpfrDS.t1dtyy;
So I don't have to built a DS for the date conversion every time.
But as @jmarkmurphy answered, I now came up with the solution of having a DS with the three/four date subfields and one overlaying subfield which is defined as DATE, so I dnon't have to use %date()
date rpgle
I don't exactly follow what you're asking. Can you provide an example of what you want to accomplish?
– jtaylor___
Mar 7 at 13:55
add a comment |
When using RPGLE's %date()
function I can "converte" a string displaying a date like '2019-01-01'
via %date('2019-01-01':*ISO)
or '20190202'
via %date('20190202':*ISO0)
into a date field.
dcl-s dateISO date(*ISO);
dateISO = %date('2019-01-01':*ISO);
dsply dateISO;
dateISO = %date('20190202':*ISO0);
dsply dateISO;
On my current database date values are split up into 3 (sometimes 4) different fields rather than stored in fields defined as 'date': On for the day part, one for the month and 1 or 2 (depends on the age of the database file) fields for either the year as 4 digit or one field for the 2 digit century and one for the 2 digit year (2019 -> stored as '2019' or '20' and '19')
In my beginning, I leard to group the 3 zoned date fields with a data structure and use the overlaying "date-subfield" for my DDS
(DSPF/PRTF
) or "working with dates".
I "discovered" for myself the beauty of DATE fields and that I can use the %date()
BIF to convert the data structure subfield, which represents the full date, to my needed date field. But for reasons, I don't want to create a new data structure for each "new" date.
So like using %subdt()
for extracting portions of a DATE or TIMESTAMP I hoped that I can edit a portion of a DATE field.
Does anyone know how to do it?
Edit:
To all those who thougt I want to GET a portion of a date: NO, I just want to EDIT (as written in the headline) a portion of the date. Like I have a DDS PF definition like this:
A R TESTPFR
A
A T1NUMB 6S 0 TEXT('Some number')
A T1TEXT 10A TEXT('Some text')
A T1DTDD 2S 0 TEXT('Day part')
A T1DTMM 2S 0 TEXT('Month part')
A T1DTYY 4S 0 TEXT('Year part')
My "old" way was like this:
**free
ctl-opt decedit('0,') datedit(*dmy) dftactgrp(*no) option(*nodebugio:*srcstmt:*nounref);
dcl-f testpf disk; // Database File
dcl-ds dateDS qualified; // DS for "converting"
date zoned(8) pos(1);
day zoned(2) pos(1);
month zoned(2) pos(3);
year zoned(4) pos(5);
end-ds;
dcl-s dateISO date(*ISO); // Destination Date field
dcl-ds testpfrDS likerec(testpfr); // Record definition if the database file
read testpfr testpfrDS;
dow (not %eof(testpf));
dateDS.day = testpfrDS.t1dtdd ; //t1dtdd is the day field
dateDs.month = testpfrDS.t1dtmm; //t1dtdd is the month field
dateDs.year = testpfrDS.t1dtyy; //t1dtdd is the year field
dateISO = %date(dateDS.date:*EUR);
dsply dateISO; // Work with the date
read testpfr testpfrDS;
enddo;
*inlr = *on;
This ment that I had to define a data structure in each new program, put the PF fields into the subfields and convert the overlaying subfield. In this case this was not that much overhead. But when having DSPF involved where the use input a range of date, I had to write a DS for the FROM date, the TO date and the date from the database. Ok I admit that I could make it like above, just make one DS and use this for the three dates. But my hope was that I can just define a date field and code someting like this:
%subdt(dateISO:*day) = testpfrDS.t1dtdd;
%subdt(dateISO:*month) = testpfrDS.t1dtmm;
%subdt(dateISO:*year) = testpfrDS.t1dtyy;
So I don't have to built a DS for the date conversion every time.
But as @jmarkmurphy answered, I now came up with the solution of having a DS with the three/four date subfields and one overlaying subfield which is defined as DATE, so I dnon't have to use %date()
date rpgle
When using RPGLE's %date()
function I can "converte" a string displaying a date like '2019-01-01'
via %date('2019-01-01':*ISO)
or '20190202'
via %date('20190202':*ISO0)
into a date field.
dcl-s dateISO date(*ISO);
dateISO = %date('2019-01-01':*ISO);
dsply dateISO;
dateISO = %date('20190202':*ISO0);
dsply dateISO;
On my current database date values are split up into 3 (sometimes 4) different fields rather than stored in fields defined as 'date': On for the day part, one for the month and 1 or 2 (depends on the age of the database file) fields for either the year as 4 digit or one field for the 2 digit century and one for the 2 digit year (2019 -> stored as '2019' or '20' and '19')
In my beginning, I leard to group the 3 zoned date fields with a data structure and use the overlaying "date-subfield" for my DDS
(DSPF/PRTF
) or "working with dates".
I "discovered" for myself the beauty of DATE fields and that I can use the %date()
BIF to convert the data structure subfield, which represents the full date, to my needed date field. But for reasons, I don't want to create a new data structure for each "new" date.
So like using %subdt()
for extracting portions of a DATE or TIMESTAMP I hoped that I can edit a portion of a DATE field.
Does anyone know how to do it?
Edit:
To all those who thougt I want to GET a portion of a date: NO, I just want to EDIT (as written in the headline) a portion of the date. Like I have a DDS PF definition like this:
A R TESTPFR
A
A T1NUMB 6S 0 TEXT('Some number')
A T1TEXT 10A TEXT('Some text')
A T1DTDD 2S 0 TEXT('Day part')
A T1DTMM 2S 0 TEXT('Month part')
A T1DTYY 4S 0 TEXT('Year part')
My "old" way was like this:
**free
ctl-opt decedit('0,') datedit(*dmy) dftactgrp(*no) option(*nodebugio:*srcstmt:*nounref);
dcl-f testpf disk; // Database File
dcl-ds dateDS qualified; // DS for "converting"
date zoned(8) pos(1);
day zoned(2) pos(1);
month zoned(2) pos(3);
year zoned(4) pos(5);
end-ds;
dcl-s dateISO date(*ISO); // Destination Date field
dcl-ds testpfrDS likerec(testpfr); // Record definition if the database file
read testpfr testpfrDS;
dow (not %eof(testpf));
dateDS.day = testpfrDS.t1dtdd ; //t1dtdd is the day field
dateDs.month = testpfrDS.t1dtmm; //t1dtdd is the month field
dateDs.year = testpfrDS.t1dtyy; //t1dtdd is the year field
dateISO = %date(dateDS.date:*EUR);
dsply dateISO; // Work with the date
read testpfr testpfrDS;
enddo;
*inlr = *on;
This ment that I had to define a data structure in each new program, put the PF fields into the subfields and convert the overlaying subfield. In this case this was not that much overhead. But when having DSPF involved where the use input a range of date, I had to write a DS for the FROM date, the TO date and the date from the database. Ok I admit that I could make it like above, just make one DS and use this for the three dates. But my hope was that I can just define a date field and code someting like this:
%subdt(dateISO:*day) = testpfrDS.t1dtdd;
%subdt(dateISO:*month) = testpfrDS.t1dtmm;
%subdt(dateISO:*year) = testpfrDS.t1dtyy;
So I don't have to built a DS for the date conversion every time.
But as @jmarkmurphy answered, I now came up with the solution of having a DS with the three/four date subfields and one overlaying subfield which is defined as DATE, so I dnon't have to use %date()
date rpgle
date rpgle
edited Mar 8 at 7:40
Radinator
asked Mar 7 at 12:31
RadinatorRadinator
1,018632
1,018632
I don't exactly follow what you're asking. Can you provide an example of what you want to accomplish?
– jtaylor___
Mar 7 at 13:55
add a comment |
I don't exactly follow what you're asking. Can you provide an example of what you want to accomplish?
– jtaylor___
Mar 7 at 13:55
I don't exactly follow what you're asking. Can you provide an example of what you want to accomplish?
– jtaylor___
Mar 7 at 13:55
I don't exactly follow what you're asking. Can you provide an example of what you want to accomplish?
– jtaylor___
Mar 7 at 13:55
add a comment |
3 Answers
3
active
oldest
votes
There is no function that allows you to edit a portion of a date, time or timestamp field. But as you said, you can do so with a data structure. Given that you don't want to create multiple data structures just for the purpose of setting the day value of multiple date fields, you could use a single Based data structure like this:
dcl-ds DateIso Qualified Based(%pDateIso);
year Signed(4:0) Pos(1);
month Signed(2:0) Pos(6);
day Signed(2:0) Pos(9);
end-ds;
dcl-s pDateIso Pointer;
dcl-s startDate Date(*iso);
dcl-s endDate Date(*iso);
pDateIso = %addr(startDate);
DateIso.day = 1;
pDateIso = %addr(endDate);
pDateIso.month = 1;
You could also leverage RPGIV to create a sub-procedure that does what you want.
dcl-proc SetDateDay;
dcl-pi *n Date(*iso);
date Date const;
day Int(5) const;
end-pi
dcl-ds *n;
dateIso Date(*iso);
dateday Signed(2:0) Pos(9);
end-ds;
dateIso = date;
dateday = day;
return dateIso;
end-proc;
1
If this is what he's asking for, another alternative is to use embedded SQL to pull the day or year from the date:exec sql set :dateDay = Day(:dateIso)
– Player1st
Mar 7 at 20:03
add a comment |
I would definitely create a set of procedures to create a Date, Time, or Timestamp from the various parts. To handle the fact that the year might be in two parts, define the fourth "century" parameter as OPTIONS(*NOPASS), and if that's not passed, the procedure would expect the year part to have all four digits.
date = makeDate(dd : mm : yy);
or
date = makeDate(dd : mm : yy: cc);
If you don't want to create a few procedures either, there's actually a way to do this without anything extra:
date = %date(cc * 1000000 + yy * 10000 + mm * 100 + dd); // untested
But that's some nasty code ...
add a comment |
Are you asking how you add or substract days, months, years, etc to an RPG date field? I think you may want to peruse the list of RPGLE built-in functions here:
https://www.ibm.com/support/knowledgecenter/en/ssw_ibm_i_73/rzasd/bifs.htm
If you click on %DAYS for instance, it will lead you to an example here: https://www.ibm.com/support/knowledgecenter/en/ssw_ibm_i_73/rzasd/bbmon.htm#bbmon__ebmonths
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55043879%2fediting-portions-of-date-field-to-compose-a-date-value%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
There is no function that allows you to edit a portion of a date, time or timestamp field. But as you said, you can do so with a data structure. Given that you don't want to create multiple data structures just for the purpose of setting the day value of multiple date fields, you could use a single Based data structure like this:
dcl-ds DateIso Qualified Based(%pDateIso);
year Signed(4:0) Pos(1);
month Signed(2:0) Pos(6);
day Signed(2:0) Pos(9);
end-ds;
dcl-s pDateIso Pointer;
dcl-s startDate Date(*iso);
dcl-s endDate Date(*iso);
pDateIso = %addr(startDate);
DateIso.day = 1;
pDateIso = %addr(endDate);
pDateIso.month = 1;
You could also leverage RPGIV to create a sub-procedure that does what you want.
dcl-proc SetDateDay;
dcl-pi *n Date(*iso);
date Date const;
day Int(5) const;
end-pi
dcl-ds *n;
dateIso Date(*iso);
dateday Signed(2:0) Pos(9);
end-ds;
dateIso = date;
dateday = day;
return dateIso;
end-proc;
1
If this is what he's asking for, another alternative is to use embedded SQL to pull the day or year from the date:exec sql set :dateDay = Day(:dateIso)
– Player1st
Mar 7 at 20:03
add a comment |
There is no function that allows you to edit a portion of a date, time or timestamp field. But as you said, you can do so with a data structure. Given that you don't want to create multiple data structures just for the purpose of setting the day value of multiple date fields, you could use a single Based data structure like this:
dcl-ds DateIso Qualified Based(%pDateIso);
year Signed(4:0) Pos(1);
month Signed(2:0) Pos(6);
day Signed(2:0) Pos(9);
end-ds;
dcl-s pDateIso Pointer;
dcl-s startDate Date(*iso);
dcl-s endDate Date(*iso);
pDateIso = %addr(startDate);
DateIso.day = 1;
pDateIso = %addr(endDate);
pDateIso.month = 1;
You could also leverage RPGIV to create a sub-procedure that does what you want.
dcl-proc SetDateDay;
dcl-pi *n Date(*iso);
date Date const;
day Int(5) const;
end-pi
dcl-ds *n;
dateIso Date(*iso);
dateday Signed(2:0) Pos(9);
end-ds;
dateIso = date;
dateday = day;
return dateIso;
end-proc;
1
If this is what he's asking for, another alternative is to use embedded SQL to pull the day or year from the date:exec sql set :dateDay = Day(:dateIso)
– Player1st
Mar 7 at 20:03
add a comment |
There is no function that allows you to edit a portion of a date, time or timestamp field. But as you said, you can do so with a data structure. Given that you don't want to create multiple data structures just for the purpose of setting the day value of multiple date fields, you could use a single Based data structure like this:
dcl-ds DateIso Qualified Based(%pDateIso);
year Signed(4:0) Pos(1);
month Signed(2:0) Pos(6);
day Signed(2:0) Pos(9);
end-ds;
dcl-s pDateIso Pointer;
dcl-s startDate Date(*iso);
dcl-s endDate Date(*iso);
pDateIso = %addr(startDate);
DateIso.day = 1;
pDateIso = %addr(endDate);
pDateIso.month = 1;
You could also leverage RPGIV to create a sub-procedure that does what you want.
dcl-proc SetDateDay;
dcl-pi *n Date(*iso);
date Date const;
day Int(5) const;
end-pi
dcl-ds *n;
dateIso Date(*iso);
dateday Signed(2:0) Pos(9);
end-ds;
dateIso = date;
dateday = day;
return dateIso;
end-proc;
There is no function that allows you to edit a portion of a date, time or timestamp field. But as you said, you can do so with a data structure. Given that you don't want to create multiple data structures just for the purpose of setting the day value of multiple date fields, you could use a single Based data structure like this:
dcl-ds DateIso Qualified Based(%pDateIso);
year Signed(4:0) Pos(1);
month Signed(2:0) Pos(6);
day Signed(2:0) Pos(9);
end-ds;
dcl-s pDateIso Pointer;
dcl-s startDate Date(*iso);
dcl-s endDate Date(*iso);
pDateIso = %addr(startDate);
DateIso.day = 1;
pDateIso = %addr(endDate);
pDateIso.month = 1;
You could also leverage RPGIV to create a sub-procedure that does what you want.
dcl-proc SetDateDay;
dcl-pi *n Date(*iso);
date Date const;
day Int(5) const;
end-pi
dcl-ds *n;
dateIso Date(*iso);
dateday Signed(2:0) Pos(9);
end-ds;
dateIso = date;
dateday = day;
return dateIso;
end-proc;
edited Mar 11 at 17:33
answered Mar 7 at 18:36
jmarkmurphyjmarkmurphy
7,9362041
7,9362041
1
If this is what he's asking for, another alternative is to use embedded SQL to pull the day or year from the date:exec sql set :dateDay = Day(:dateIso)
– Player1st
Mar 7 at 20:03
add a comment |
1
If this is what he's asking for, another alternative is to use embedded SQL to pull the day or year from the date:exec sql set :dateDay = Day(:dateIso)
– Player1st
Mar 7 at 20:03
1
1
If this is what he's asking for, another alternative is to use embedded SQL to pull the day or year from the date:
exec sql set :dateDay = Day(:dateIso)
– Player1st
Mar 7 at 20:03
If this is what he's asking for, another alternative is to use embedded SQL to pull the day or year from the date:
exec sql set :dateDay = Day(:dateIso)
– Player1st
Mar 7 at 20:03
add a comment |
I would definitely create a set of procedures to create a Date, Time, or Timestamp from the various parts. To handle the fact that the year might be in two parts, define the fourth "century" parameter as OPTIONS(*NOPASS), and if that's not passed, the procedure would expect the year part to have all four digits.
date = makeDate(dd : mm : yy);
or
date = makeDate(dd : mm : yy: cc);
If you don't want to create a few procedures either, there's actually a way to do this without anything extra:
date = %date(cc * 1000000 + yy * 10000 + mm * 100 + dd); // untested
But that's some nasty code ...
add a comment |
I would definitely create a set of procedures to create a Date, Time, or Timestamp from the various parts. To handle the fact that the year might be in two parts, define the fourth "century" parameter as OPTIONS(*NOPASS), and if that's not passed, the procedure would expect the year part to have all four digits.
date = makeDate(dd : mm : yy);
or
date = makeDate(dd : mm : yy: cc);
If you don't want to create a few procedures either, there's actually a way to do this without anything extra:
date = %date(cc * 1000000 + yy * 10000 + mm * 100 + dd); // untested
But that's some nasty code ...
add a comment |
I would definitely create a set of procedures to create a Date, Time, or Timestamp from the various parts. To handle the fact that the year might be in two parts, define the fourth "century" parameter as OPTIONS(*NOPASS), and if that's not passed, the procedure would expect the year part to have all four digits.
date = makeDate(dd : mm : yy);
or
date = makeDate(dd : mm : yy: cc);
If you don't want to create a few procedures either, there's actually a way to do this without anything extra:
date = %date(cc * 1000000 + yy * 10000 + mm * 100 + dd); // untested
But that's some nasty code ...
I would definitely create a set of procedures to create a Date, Time, or Timestamp from the various parts. To handle the fact that the year might be in two parts, define the fourth "century" parameter as OPTIONS(*NOPASS), and if that's not passed, the procedure would expect the year part to have all four digits.
date = makeDate(dd : mm : yy);
or
date = makeDate(dd : mm : yy: cc);
If you don't want to create a few procedures either, there's actually a way to do this without anything extra:
date = %date(cc * 1000000 + yy * 10000 + mm * 100 + dd); // untested
But that's some nasty code ...
answered Mar 7 at 22:15
Barbara MorrisBarbara Morris
1,17445
1,17445
add a comment |
add a comment |
Are you asking how you add or substract days, months, years, etc to an RPG date field? I think you may want to peruse the list of RPGLE built-in functions here:
https://www.ibm.com/support/knowledgecenter/en/ssw_ibm_i_73/rzasd/bifs.htm
If you click on %DAYS for instance, it will lead you to an example here: https://www.ibm.com/support/knowledgecenter/en/ssw_ibm_i_73/rzasd/bbmon.htm#bbmon__ebmonths
add a comment |
Are you asking how you add or substract days, months, years, etc to an RPG date field? I think you may want to peruse the list of RPGLE built-in functions here:
https://www.ibm.com/support/knowledgecenter/en/ssw_ibm_i_73/rzasd/bifs.htm
If you click on %DAYS for instance, it will lead you to an example here: https://www.ibm.com/support/knowledgecenter/en/ssw_ibm_i_73/rzasd/bbmon.htm#bbmon__ebmonths
add a comment |
Are you asking how you add or substract days, months, years, etc to an RPG date field? I think you may want to peruse the list of RPGLE built-in functions here:
https://www.ibm.com/support/knowledgecenter/en/ssw_ibm_i_73/rzasd/bifs.htm
If you click on %DAYS for instance, it will lead you to an example here: https://www.ibm.com/support/knowledgecenter/en/ssw_ibm_i_73/rzasd/bbmon.htm#bbmon__ebmonths
Are you asking how you add or substract days, months, years, etc to an RPG date field? I think you may want to peruse the list of RPGLE built-in functions here:
https://www.ibm.com/support/knowledgecenter/en/ssw_ibm_i_73/rzasd/bifs.htm
If you click on %DAYS for instance, it will lead you to an example here: https://www.ibm.com/support/knowledgecenter/en/ssw_ibm_i_73/rzasd/bbmon.htm#bbmon__ebmonths
answered Mar 7 at 17:35
Player1stPlayer1st
1,033713
1,033713
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55043879%2fediting-portions-of-date-field-to-compose-a-date-value%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
I don't exactly follow what you're asking. Can you provide an example of what you want to accomplish?
– jtaylor___
Mar 7 at 13:55