Day Number In a Pattern
I have some data that shows shift span details for my workers. I am trying to figure a way, if there is one, to establish the first day startdaynum
of the span as 1 and then appropriately label any proceeding enddaynum
or startdaynum
after that to be 2 if the start date/time or end date/time is 1 day after the start, or 3 if the dates are 2 days after the start, so on and so forth.
Below I have some sample data, all of it is real data except for the startdaynum
and enddaynum
columns that I have manually populated to show what I am trying to achieve. The last column shiftsegmentid
is unique to every row. The second to last column shiftcodeid
is unique to each shift. So that would be the one where we could determine if the row we are evaluating is a continuance of the previous row or the first row of a shift, if this could be done with something analytically.
The first 2 rows are all 1 shift where all the start end dates are the same. The second 2 rows are 1 shift together where the first end date is the day after the first start date, so I want startdaynum=1
but enddate=2
. Row 2 are both the day after the first start date of that shift so the should be startdaynum=2
and enddate=2
, as displayed.
NAME DESCRIPTION TYPE STARTDAYNUM STARTTIME ENDDAYNUM ENDTIME SHECDHOURS SKILLSANDCERTS TRANSFER SHIFTCODEID SHIFTSEGMENTID
------- ----------- -------- ----------- ------------------- --------- ------------------- ---------- -------------- ------------ ----------- --------------
1009ABC Pattern 1 Transfer 1 01/01/1900 05:00 am 1 01/01/1900 01:30 pm 8.5 ///800505/// 3050 4052
1009ABC Pattern 1 Transfer 1 01/01/1900 01:30 pm 1 01/01/1900 02:30 pm 1 ///800855/// 3050 4053
1009XYZ Pattern 2 Transfer 1 01/01/1900 05:00 pm 2 01/02/1900 01:30 am 8.5 ///800505/// 3070 4072
1009XYZ Pattern 2 Transfer 2 01/02/1900 01:30 am 2 01/02/1900 02:30 am 1 ///800855/// 3070 4073
sql oracle
add a comment |
I have some data that shows shift span details for my workers. I am trying to figure a way, if there is one, to establish the first day startdaynum
of the span as 1 and then appropriately label any proceeding enddaynum
or startdaynum
after that to be 2 if the start date/time or end date/time is 1 day after the start, or 3 if the dates are 2 days after the start, so on and so forth.
Below I have some sample data, all of it is real data except for the startdaynum
and enddaynum
columns that I have manually populated to show what I am trying to achieve. The last column shiftsegmentid
is unique to every row. The second to last column shiftcodeid
is unique to each shift. So that would be the one where we could determine if the row we are evaluating is a continuance of the previous row or the first row of a shift, if this could be done with something analytically.
The first 2 rows are all 1 shift where all the start end dates are the same. The second 2 rows are 1 shift together where the first end date is the day after the first start date, so I want startdaynum=1
but enddate=2
. Row 2 are both the day after the first start date of that shift so the should be startdaynum=2
and enddate=2
, as displayed.
NAME DESCRIPTION TYPE STARTDAYNUM STARTTIME ENDDAYNUM ENDTIME SHECDHOURS SKILLSANDCERTS TRANSFER SHIFTCODEID SHIFTSEGMENTID
------- ----------- -------- ----------- ------------------- --------- ------------------- ---------- -------------- ------------ ----------- --------------
1009ABC Pattern 1 Transfer 1 01/01/1900 05:00 am 1 01/01/1900 01:30 pm 8.5 ///800505/// 3050 4052
1009ABC Pattern 1 Transfer 1 01/01/1900 01:30 pm 1 01/01/1900 02:30 pm 1 ///800855/// 3050 4053
1009XYZ Pattern 2 Transfer 1 01/01/1900 05:00 pm 2 01/02/1900 01:30 am 8.5 ///800505/// 3070 4072
1009XYZ Pattern 2 Transfer 2 01/02/1900 01:30 am 2 01/02/1900 02:30 am 1 ///800855/// 3070 4073
sql oracle
The date parts of your start/end times seem to be nominal and set from the start of 1900; so isn't the day number from those what you're after anyway?
– Alex Poole
Nov 20 at 17:44
I didn't think of that but yes that makes sense. The application doesn't actually use a date since the shifts are just times that can be applied to any day(s). Thanks for the reply I think your suggestion will work out!
– sandsawks
Nov 20 at 18:07
add a comment |
I have some data that shows shift span details for my workers. I am trying to figure a way, if there is one, to establish the first day startdaynum
of the span as 1 and then appropriately label any proceeding enddaynum
or startdaynum
after that to be 2 if the start date/time or end date/time is 1 day after the start, or 3 if the dates are 2 days after the start, so on and so forth.
Below I have some sample data, all of it is real data except for the startdaynum
and enddaynum
columns that I have manually populated to show what I am trying to achieve. The last column shiftsegmentid
is unique to every row. The second to last column shiftcodeid
is unique to each shift. So that would be the one where we could determine if the row we are evaluating is a continuance of the previous row or the first row of a shift, if this could be done with something analytically.
The first 2 rows are all 1 shift where all the start end dates are the same. The second 2 rows are 1 shift together where the first end date is the day after the first start date, so I want startdaynum=1
but enddate=2
. Row 2 are both the day after the first start date of that shift so the should be startdaynum=2
and enddate=2
, as displayed.
NAME DESCRIPTION TYPE STARTDAYNUM STARTTIME ENDDAYNUM ENDTIME SHECDHOURS SKILLSANDCERTS TRANSFER SHIFTCODEID SHIFTSEGMENTID
------- ----------- -------- ----------- ------------------- --------- ------------------- ---------- -------------- ------------ ----------- --------------
1009ABC Pattern 1 Transfer 1 01/01/1900 05:00 am 1 01/01/1900 01:30 pm 8.5 ///800505/// 3050 4052
1009ABC Pattern 1 Transfer 1 01/01/1900 01:30 pm 1 01/01/1900 02:30 pm 1 ///800855/// 3050 4053
1009XYZ Pattern 2 Transfer 1 01/01/1900 05:00 pm 2 01/02/1900 01:30 am 8.5 ///800505/// 3070 4072
1009XYZ Pattern 2 Transfer 2 01/02/1900 01:30 am 2 01/02/1900 02:30 am 1 ///800855/// 3070 4073
sql oracle
I have some data that shows shift span details for my workers. I am trying to figure a way, if there is one, to establish the first day startdaynum
of the span as 1 and then appropriately label any proceeding enddaynum
or startdaynum
after that to be 2 if the start date/time or end date/time is 1 day after the start, or 3 if the dates are 2 days after the start, so on and so forth.
Below I have some sample data, all of it is real data except for the startdaynum
and enddaynum
columns that I have manually populated to show what I am trying to achieve. The last column shiftsegmentid
is unique to every row. The second to last column shiftcodeid
is unique to each shift. So that would be the one where we could determine if the row we are evaluating is a continuance of the previous row or the first row of a shift, if this could be done with something analytically.
The first 2 rows are all 1 shift where all the start end dates are the same. The second 2 rows are 1 shift together where the first end date is the day after the first start date, so I want startdaynum=1
but enddate=2
. Row 2 are both the day after the first start date of that shift so the should be startdaynum=2
and enddate=2
, as displayed.
NAME DESCRIPTION TYPE STARTDAYNUM STARTTIME ENDDAYNUM ENDTIME SHECDHOURS SKILLSANDCERTS TRANSFER SHIFTCODEID SHIFTSEGMENTID
------- ----------- -------- ----------- ------------------- --------- ------------------- ---------- -------------- ------------ ----------- --------------
1009ABC Pattern 1 Transfer 1 01/01/1900 05:00 am 1 01/01/1900 01:30 pm 8.5 ///800505/// 3050 4052
1009ABC Pattern 1 Transfer 1 01/01/1900 01:30 pm 1 01/01/1900 02:30 pm 1 ///800855/// 3050 4053
1009XYZ Pattern 2 Transfer 1 01/01/1900 05:00 pm 2 01/02/1900 01:30 am 8.5 ///800505/// 3070 4072
1009XYZ Pattern 2 Transfer 2 01/02/1900 01:30 am 2 01/02/1900 02:30 am 1 ///800855/// 3070 4073
sql oracle
sql oracle
edited Nov 20 at 17:37
Alex Poole
129k6101176
129k6101176
asked Nov 20 at 17:21
sandsawks
505
505
The date parts of your start/end times seem to be nominal and set from the start of 1900; so isn't the day number from those what you're after anyway?
– Alex Poole
Nov 20 at 17:44
I didn't think of that but yes that makes sense. The application doesn't actually use a date since the shifts are just times that can be applied to any day(s). Thanks for the reply I think your suggestion will work out!
– sandsawks
Nov 20 at 18:07
add a comment |
The date parts of your start/end times seem to be nominal and set from the start of 1900; so isn't the day number from those what you're after anyway?
– Alex Poole
Nov 20 at 17:44
I didn't think of that but yes that makes sense. The application doesn't actually use a date since the shifts are just times that can be applied to any day(s). Thanks for the reply I think your suggestion will work out!
– sandsawks
Nov 20 at 18:07
The date parts of your start/end times seem to be nominal and set from the start of 1900; so isn't the day number from those what you're after anyway?
– Alex Poole
Nov 20 at 17:44
The date parts of your start/end times seem to be nominal and set from the start of 1900; so isn't the day number from those what you're after anyway?
– Alex Poole
Nov 20 at 17:44
I didn't think of that but yes that makes sense. The application doesn't actually use a date since the shifts are just times that can be applied to any day(s). Thanks for the reply I think your suggestion will work out!
– sandsawks
Nov 20 at 18:07
I didn't think of that but yes that makes sense. The application doesn't actually use a date since the shifts are just times that can be applied to any day(s). Thanks for the reply I think your suggestion will work out!
– sandsawks
Nov 20 at 18:07
add a comment |
1 Answer
1
active
oldest
votes
Based on your sample data and comments, the start and end time columns already include the information you're looking for in the nominal date part, so you don't need to do anything complicated to find adjaacent records etc.
You can just use:
extract(day from starttime) as startdaynum
and
extract(day from endtime) as enddaynum
Demo:
with your_table (name, description, type, starttime, endtime, shecdhours, skillsandcerts, transfer, shiftcodeid, shiftsegmentid) as (
select '1009ABC', 'Pattern 1', 'Transfer', to_date('01/01/1900 05:00 am', 'MM/DD/YYYY HH:MI am'), to_date('01/01/1900 01:30 pm', 'MM/DD/YYYY HH:MI am'), 8.5, null, '///800505///', 3050, 4052 from dual
union all
select '1009ABC', 'Pattern 1', 'Transfer', to_date('01/01/1900 01:30 pm', 'MM/DD/YYYY HH:MI am'), to_date('01/01/1900 02:30 pm', 'MM/DD/YYYY HH:MI am'), 1, null, '///800855///', 3050, 4053 from dual
union all
select '1009XYZ', 'Pattern 2', 'Transfer', to_date('01/01/1900 05:00 pm', 'MM/DD/YYYY HH:MI am'), to_date('01/02/1900 01:30 am', 'MM/DD/YYYY HH:MI am'), 8.5, null, '///800505///', 3070, 4072 from dual
union all
select '1009XYZ', 'Pattern 2', 'Transfer', to_date('01/02/1900 01:30 am', 'MM/DD/YYYY HH:MI am'), to_date('01/02/1900 02:30 am', 'MM/DD/YYYY HH:MI am'), 1, null, '///800855///', 3070, 4073 from dual
)
select name,
description,
extract(day from starttime) as startdaynum,
to_char(starttime, 'HH:MI am') as starttime,
extract(day from endtime) as enddaynum,
to_char(endtime, 'HH:MI am') as endtime,
shecdhours,
skillsandcerts,
transfer,
shiftcodeid,
shiftsegmentid
from your_table;
NAME DESCRIPTI STARTDAYNUM STARTTIM ENDDAYNUM ENDTIME SHECDHOURS SKILLSANDCERTS TRANSFER SHIFTCODEID SHIFTSEGMENTID
------- --------- ----------- -------- ---------- -------- ---------- -------------- ------------ ----------- --------------
1009ABC Pattern 1 1 05:00 AM 1 01:30 PM 8.5 ///800505/// 3050 4052
1009ABC Pattern 1 1 01:30 PM 1 02:30 PM 1 ///800855/// 3050 4053
1009XYZ Pattern 2 1 05:00 PM 2 01:30 AM 8.5 ///800505/// 3070 4072
1009XYZ Pattern 2 2 01:30 AM 2 02:30 AM 1 ///800855/// 3070 4073
Thanks Alex, worked perfect.
– sandsawks
Nov 20 at 18:25
@sandsawks Upvote if the answer helped the resolve the issue or has contributed to coming to a logical conclusion.
– Jåcob
Nov 20 at 18:32
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%2f53398274%2fday-number-in-a-pattern%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Based on your sample data and comments, the start and end time columns already include the information you're looking for in the nominal date part, so you don't need to do anything complicated to find adjaacent records etc.
You can just use:
extract(day from starttime) as startdaynum
and
extract(day from endtime) as enddaynum
Demo:
with your_table (name, description, type, starttime, endtime, shecdhours, skillsandcerts, transfer, shiftcodeid, shiftsegmentid) as (
select '1009ABC', 'Pattern 1', 'Transfer', to_date('01/01/1900 05:00 am', 'MM/DD/YYYY HH:MI am'), to_date('01/01/1900 01:30 pm', 'MM/DD/YYYY HH:MI am'), 8.5, null, '///800505///', 3050, 4052 from dual
union all
select '1009ABC', 'Pattern 1', 'Transfer', to_date('01/01/1900 01:30 pm', 'MM/DD/YYYY HH:MI am'), to_date('01/01/1900 02:30 pm', 'MM/DD/YYYY HH:MI am'), 1, null, '///800855///', 3050, 4053 from dual
union all
select '1009XYZ', 'Pattern 2', 'Transfer', to_date('01/01/1900 05:00 pm', 'MM/DD/YYYY HH:MI am'), to_date('01/02/1900 01:30 am', 'MM/DD/YYYY HH:MI am'), 8.5, null, '///800505///', 3070, 4072 from dual
union all
select '1009XYZ', 'Pattern 2', 'Transfer', to_date('01/02/1900 01:30 am', 'MM/DD/YYYY HH:MI am'), to_date('01/02/1900 02:30 am', 'MM/DD/YYYY HH:MI am'), 1, null, '///800855///', 3070, 4073 from dual
)
select name,
description,
extract(day from starttime) as startdaynum,
to_char(starttime, 'HH:MI am') as starttime,
extract(day from endtime) as enddaynum,
to_char(endtime, 'HH:MI am') as endtime,
shecdhours,
skillsandcerts,
transfer,
shiftcodeid,
shiftsegmentid
from your_table;
NAME DESCRIPTI STARTDAYNUM STARTTIM ENDDAYNUM ENDTIME SHECDHOURS SKILLSANDCERTS TRANSFER SHIFTCODEID SHIFTSEGMENTID
------- --------- ----------- -------- ---------- -------- ---------- -------------- ------------ ----------- --------------
1009ABC Pattern 1 1 05:00 AM 1 01:30 PM 8.5 ///800505/// 3050 4052
1009ABC Pattern 1 1 01:30 PM 1 02:30 PM 1 ///800855/// 3050 4053
1009XYZ Pattern 2 1 05:00 PM 2 01:30 AM 8.5 ///800505/// 3070 4072
1009XYZ Pattern 2 2 01:30 AM 2 02:30 AM 1 ///800855/// 3070 4073
Thanks Alex, worked perfect.
– sandsawks
Nov 20 at 18:25
@sandsawks Upvote if the answer helped the resolve the issue or has contributed to coming to a logical conclusion.
– Jåcob
Nov 20 at 18:32
add a comment |
Based on your sample data and comments, the start and end time columns already include the information you're looking for in the nominal date part, so you don't need to do anything complicated to find adjaacent records etc.
You can just use:
extract(day from starttime) as startdaynum
and
extract(day from endtime) as enddaynum
Demo:
with your_table (name, description, type, starttime, endtime, shecdhours, skillsandcerts, transfer, shiftcodeid, shiftsegmentid) as (
select '1009ABC', 'Pattern 1', 'Transfer', to_date('01/01/1900 05:00 am', 'MM/DD/YYYY HH:MI am'), to_date('01/01/1900 01:30 pm', 'MM/DD/YYYY HH:MI am'), 8.5, null, '///800505///', 3050, 4052 from dual
union all
select '1009ABC', 'Pattern 1', 'Transfer', to_date('01/01/1900 01:30 pm', 'MM/DD/YYYY HH:MI am'), to_date('01/01/1900 02:30 pm', 'MM/DD/YYYY HH:MI am'), 1, null, '///800855///', 3050, 4053 from dual
union all
select '1009XYZ', 'Pattern 2', 'Transfer', to_date('01/01/1900 05:00 pm', 'MM/DD/YYYY HH:MI am'), to_date('01/02/1900 01:30 am', 'MM/DD/YYYY HH:MI am'), 8.5, null, '///800505///', 3070, 4072 from dual
union all
select '1009XYZ', 'Pattern 2', 'Transfer', to_date('01/02/1900 01:30 am', 'MM/DD/YYYY HH:MI am'), to_date('01/02/1900 02:30 am', 'MM/DD/YYYY HH:MI am'), 1, null, '///800855///', 3070, 4073 from dual
)
select name,
description,
extract(day from starttime) as startdaynum,
to_char(starttime, 'HH:MI am') as starttime,
extract(day from endtime) as enddaynum,
to_char(endtime, 'HH:MI am') as endtime,
shecdhours,
skillsandcerts,
transfer,
shiftcodeid,
shiftsegmentid
from your_table;
NAME DESCRIPTI STARTDAYNUM STARTTIM ENDDAYNUM ENDTIME SHECDHOURS SKILLSANDCERTS TRANSFER SHIFTCODEID SHIFTSEGMENTID
------- --------- ----------- -------- ---------- -------- ---------- -------------- ------------ ----------- --------------
1009ABC Pattern 1 1 05:00 AM 1 01:30 PM 8.5 ///800505/// 3050 4052
1009ABC Pattern 1 1 01:30 PM 1 02:30 PM 1 ///800855/// 3050 4053
1009XYZ Pattern 2 1 05:00 PM 2 01:30 AM 8.5 ///800505/// 3070 4072
1009XYZ Pattern 2 2 01:30 AM 2 02:30 AM 1 ///800855/// 3070 4073
Thanks Alex, worked perfect.
– sandsawks
Nov 20 at 18:25
@sandsawks Upvote if the answer helped the resolve the issue or has contributed to coming to a logical conclusion.
– Jåcob
Nov 20 at 18:32
add a comment |
Based on your sample data and comments, the start and end time columns already include the information you're looking for in the nominal date part, so you don't need to do anything complicated to find adjaacent records etc.
You can just use:
extract(day from starttime) as startdaynum
and
extract(day from endtime) as enddaynum
Demo:
with your_table (name, description, type, starttime, endtime, shecdhours, skillsandcerts, transfer, shiftcodeid, shiftsegmentid) as (
select '1009ABC', 'Pattern 1', 'Transfer', to_date('01/01/1900 05:00 am', 'MM/DD/YYYY HH:MI am'), to_date('01/01/1900 01:30 pm', 'MM/DD/YYYY HH:MI am'), 8.5, null, '///800505///', 3050, 4052 from dual
union all
select '1009ABC', 'Pattern 1', 'Transfer', to_date('01/01/1900 01:30 pm', 'MM/DD/YYYY HH:MI am'), to_date('01/01/1900 02:30 pm', 'MM/DD/YYYY HH:MI am'), 1, null, '///800855///', 3050, 4053 from dual
union all
select '1009XYZ', 'Pattern 2', 'Transfer', to_date('01/01/1900 05:00 pm', 'MM/DD/YYYY HH:MI am'), to_date('01/02/1900 01:30 am', 'MM/DD/YYYY HH:MI am'), 8.5, null, '///800505///', 3070, 4072 from dual
union all
select '1009XYZ', 'Pattern 2', 'Transfer', to_date('01/02/1900 01:30 am', 'MM/DD/YYYY HH:MI am'), to_date('01/02/1900 02:30 am', 'MM/DD/YYYY HH:MI am'), 1, null, '///800855///', 3070, 4073 from dual
)
select name,
description,
extract(day from starttime) as startdaynum,
to_char(starttime, 'HH:MI am') as starttime,
extract(day from endtime) as enddaynum,
to_char(endtime, 'HH:MI am') as endtime,
shecdhours,
skillsandcerts,
transfer,
shiftcodeid,
shiftsegmentid
from your_table;
NAME DESCRIPTI STARTDAYNUM STARTTIM ENDDAYNUM ENDTIME SHECDHOURS SKILLSANDCERTS TRANSFER SHIFTCODEID SHIFTSEGMENTID
------- --------- ----------- -------- ---------- -------- ---------- -------------- ------------ ----------- --------------
1009ABC Pattern 1 1 05:00 AM 1 01:30 PM 8.5 ///800505/// 3050 4052
1009ABC Pattern 1 1 01:30 PM 1 02:30 PM 1 ///800855/// 3050 4053
1009XYZ Pattern 2 1 05:00 PM 2 01:30 AM 8.5 ///800505/// 3070 4072
1009XYZ Pattern 2 2 01:30 AM 2 02:30 AM 1 ///800855/// 3070 4073
Based on your sample data and comments, the start and end time columns already include the information you're looking for in the nominal date part, so you don't need to do anything complicated to find adjaacent records etc.
You can just use:
extract(day from starttime) as startdaynum
and
extract(day from endtime) as enddaynum
Demo:
with your_table (name, description, type, starttime, endtime, shecdhours, skillsandcerts, transfer, shiftcodeid, shiftsegmentid) as (
select '1009ABC', 'Pattern 1', 'Transfer', to_date('01/01/1900 05:00 am', 'MM/DD/YYYY HH:MI am'), to_date('01/01/1900 01:30 pm', 'MM/DD/YYYY HH:MI am'), 8.5, null, '///800505///', 3050, 4052 from dual
union all
select '1009ABC', 'Pattern 1', 'Transfer', to_date('01/01/1900 01:30 pm', 'MM/DD/YYYY HH:MI am'), to_date('01/01/1900 02:30 pm', 'MM/DD/YYYY HH:MI am'), 1, null, '///800855///', 3050, 4053 from dual
union all
select '1009XYZ', 'Pattern 2', 'Transfer', to_date('01/01/1900 05:00 pm', 'MM/DD/YYYY HH:MI am'), to_date('01/02/1900 01:30 am', 'MM/DD/YYYY HH:MI am'), 8.5, null, '///800505///', 3070, 4072 from dual
union all
select '1009XYZ', 'Pattern 2', 'Transfer', to_date('01/02/1900 01:30 am', 'MM/DD/YYYY HH:MI am'), to_date('01/02/1900 02:30 am', 'MM/DD/YYYY HH:MI am'), 1, null, '///800855///', 3070, 4073 from dual
)
select name,
description,
extract(day from starttime) as startdaynum,
to_char(starttime, 'HH:MI am') as starttime,
extract(day from endtime) as enddaynum,
to_char(endtime, 'HH:MI am') as endtime,
shecdhours,
skillsandcerts,
transfer,
shiftcodeid,
shiftsegmentid
from your_table;
NAME DESCRIPTI STARTDAYNUM STARTTIM ENDDAYNUM ENDTIME SHECDHOURS SKILLSANDCERTS TRANSFER SHIFTCODEID SHIFTSEGMENTID
------- --------- ----------- -------- ---------- -------- ---------- -------------- ------------ ----------- --------------
1009ABC Pattern 1 1 05:00 AM 1 01:30 PM 8.5 ///800505/// 3050 4052
1009ABC Pattern 1 1 01:30 PM 1 02:30 PM 1 ///800855/// 3050 4053
1009XYZ Pattern 2 1 05:00 PM 2 01:30 AM 8.5 ///800505/// 3070 4072
1009XYZ Pattern 2 2 01:30 AM 2 02:30 AM 1 ///800855/// 3070 4073
answered Nov 20 at 18:18
Alex Poole
129k6101176
129k6101176
Thanks Alex, worked perfect.
– sandsawks
Nov 20 at 18:25
@sandsawks Upvote if the answer helped the resolve the issue or has contributed to coming to a logical conclusion.
– Jåcob
Nov 20 at 18:32
add a comment |
Thanks Alex, worked perfect.
– sandsawks
Nov 20 at 18:25
@sandsawks Upvote if the answer helped the resolve the issue or has contributed to coming to a logical conclusion.
– Jåcob
Nov 20 at 18:32
Thanks Alex, worked perfect.
– sandsawks
Nov 20 at 18:25
Thanks Alex, worked perfect.
– sandsawks
Nov 20 at 18:25
@sandsawks Upvote if the answer helped the resolve the issue or has contributed to coming to a logical conclusion.
– Jåcob
Nov 20 at 18:32
@sandsawks Upvote if the answer helped the resolve the issue or has contributed to coming to a logical conclusion.
– Jåcob
Nov 20 at 18:32
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.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- 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%2f53398274%2fday-number-in-a-pattern%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
The date parts of your start/end times seem to be nominal and set from the start of 1900; so isn't the day number from those what you're after anyway?
– Alex Poole
Nov 20 at 17:44
I didn't think of that but yes that makes sense. The application doesn't actually use a date since the shifts are just times that can be applied to any day(s). Thanks for the reply I think your suggestion will work out!
– sandsawks
Nov 20 at 18:07