Solved

set date as 23:59:59 pm instead of 12 am

Posted on 2013-12-17
4
590 Views
Last Modified: 2013-12-17
I am sending a date variable for start time and end time
The start time is find being automatically set to 12 am
However I need to end date to be set to 23:59:59

below are the code fragments that address the date:


 IN fromDate varchar (50),
        IN toDate varchar (50),
        IN timeZone varchar (50))

    BEGIN
            DECLARE startDate varchar (50);
            DECLARE endDate varchar (50);
            DECLARE mylogID Int;

             SET startDate = FROM_UNIXTIME(fromDate/1000);
             SET endDate = FROM_UNIXTIME(toDate/1000);

time_to_sec(timediff(endDate, startDate)) / 3600 AS totalTimeRange

Open in new window

0
Comment
Question by:portlight
  • 2
4 Comments
 
LVL 34

Expert Comment

by:Dan Craciun
ID: 39725808
I don't get it. 12 am is 00:00:00. Why do you need the end time to be a second before start time?
0
 

Author Comment

by:portlight
ID: 39725814
If the start date is 1/4/2014 the time always is 00:00:00
If the end date is 1/6/2014 the time is always 00:00:00
 
There 23 hours, 59 minutes and 59 seconds left in the 1/6/2014 day that are exlcuded from the range difference.
so I need the range to be midnight of the start date to 23:59 on the end date
NOT midnight to midnight - leaving out a full day.
0
 
LVL 34

Accepted Solution

by:
Dan Craciun earned 500 total points
ID: 39725832
Well, replace
time_to_sec(timediff(endDate, startDate)) / 3600 AS totalTimeRange

with
time_to_sec(timediff(DATE_ADD(endDate, INTERVAL 1 DAY), startDate)) / 3600 AS totalTimeRange

This will add a day to your endDate, effectively putting you within 1 sec of your target time.

HTH,
Dan
0
 
LVL 9

Expert Comment

by:QuinnDex
ID: 39725852
how are you storing end date, for the time to be 00:00:00 it would indicate you are storing date only, that works for start date but for end date you need to store date and time, you can hard code the 23:59:59 into the code.

so you would store date and time in this format "2014/01/06 23:59:59"
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

APEX (Application Express) is used to develop a web application from Oracle. SQL Workshop is one of the tools that comes with Oracle APEX to query or modify the database objects or to make any changes to the structure.
Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now