BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
BETO
Fluorite | Level 6

HI ,

i've a question. I have a report that shows all the tickets open in a 24 hr period. If the ticket is open at 8 am thru 8 pm  we have a 4 hr window to work ticket. The issue is if the ticket opens after 8 pm - 8 am  the office is close so the ticket can't be worked within the 4 hr window. I was wondering if there is a way to create an if statement where ticket open at off hrs to  default to 8 am?  For example

the ticket open. At

09Aug 2013 09::24:00 PM   

I Would like to see

10Aug 2013 08:00:00 AM

THanks for your assistance

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

Something like this perhaps assuming your ticket open datetime variable is named TicketOpen.

if hour(TicketOpen) ge 16 then ActualTicketOpen = DHMS((datepart(TicketOpen)+1),8,0,0);

else ActualTicketOpen=TicketOpen;

Apply the same format to the ActualTicketOpen, or what ever you might decide to call it, as TicketOpen.

Depending on your actual business rulesyou may want to change the GE to GT (or > ) if you do want to have the 09Aug 2012 08:00:00PM treatet as opened on 09 instead of 10 Aug.

View solution in original post

7 REPLIES 7
ballardw
Super User

Something like this perhaps assuming your ticket open datetime variable is named TicketOpen.

if hour(TicketOpen) ge 16 then ActualTicketOpen = DHMS((datepart(TicketOpen)+1),8,0,0);

else ActualTicketOpen=TicketOpen;

Apply the same format to the ActualTicketOpen, or what ever you might decide to call it, as TicketOpen.

Depending on your actual business rulesyou may want to change the GE to GT (or > ) if you do want to have the 09Aug 2012 08:00:00PM treatet as opened on 09 instead of 10 Aug.

BETO
Fluorite | Level 6

THank you for response I do have a question what does 16 equal to is that military time for 4 o'clock ?

Fugue
Quartz | Level 8

You will need to modfiy BallardW's suggestion to deal with calls before 8am. In response to your question, 20:00 hours is 8pm in military time.

Adaptation of Ballardw's code to deal with pre-8am and post-8pm . . .

if hour(TicketOpen) lt 8 then ActualTicketOpen = DHMS((datepart(TicketOpen)),8,0,0);

else if hour(TicketOpen) ge 20 then ActualTicketOpen = DHMS((datepart(TicketOpen)+1),8,0,0);

else ActualTicketOpen=TicketOpen;

BETO
Fluorite | Level 6

Hi Fugue,

Thanks for the response when I run the script I get this out put--- 1691569440 the start date I have is 08aug2013 0;8:24:00 is that a formatting issue ? Thanks again

BETO
Fluorite | Level 6

How can I apply the between statement  to include from 20-23 and from 00 - 8 in hours ? I actually fig it out the format issue an the script works thanks again Is it possible to add the between statement?

Fugue
Quartz | Level 8

In a data step, the code would look something like . . .

if 0<= hour(TicketOpen) < 8 then ActualTicketOpen = DHMS((datepart(TicketOpen)),8,0,0);

else if 20<= hour(TicketOpen) <=23 then ActualTicketOpen = DHMS((datepart(TicketOpen)+1),8,0,0);

else ActualTicketOpen=TicketOpen;

jakarman
Barite | Level 11

Knowing all exceptions opening times etc you can code it all.
An other approach is just keep the INTNX INTCK fucntions. The are meant to deal with time/date shifting.

Using the INTERVALDS option, see SAS(R) 9.3 System Options: Reference, Second Edition. You can define sliding dates /times accourding own definitions. It are some addtional concepts changing releases SAS(R) 9.3 Language Reference: Concepts, Second Edition (datetime concepts) custom intervals. The r445 544 454 options might be also handy.

The concept is: Define a dataset with your valid (opening hours) ordered!. All durations will be adjusted according that  

---->-- ja karman --<-----

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 7 replies
  • 950 views
  • 3 likes
  • 4 in conversation