# CTIME and CDATE Help

### #1

Posted 22 August 2008 - 12:55 PM

Here is my code:

$CURDATETIME = CDATE(@DATE,'MMDDYYYY') + @TIME

IF $EDION = 'Y'

$ONTIME = $ONDATETIME(9,14)

#ONTIME = CTIME($ONTIME) + CTIME('000500')

$ONTIME = CTIME(#ONTIME)

$$ONDATETIME = $ONDATETIME(1,8) + $ONTIME

IF $CURDATETIME > $$ONDATETIME

etc....

Any suggestions on how I can use the date and time together to account for the date change would be greatly appreciated!

Thanks in advance,

David

### #2

Posted 22 August 2008 - 04:00 PM

DaveI am new to PRO IV and need some help. I am trying to take a date and time and add 5 minutes to it and then compare it to the current date and time. It works except between 23:55 and 00:00.

Here is my code:

$CURDATETIME = CDATE(@DATE,'MMDDYYYY') + @TIME

IF $EDION = 'Y'

$ONTIME = $ONDATETIME(9,14)

#ONTIME = CTIME($ONTIME) + CTIME('000500')

$ONTIME = CTIME(#ONTIME)

$ONDATETIME = $ONDATETIME(1,8) + $ONTIME

IF $CURDATETIME > $ONDATETIME

etc....

Any suggestions on how I can use the date and time together to account for the date change would be greatly appreciated!

Thanks in advance,

David

Because CTIME converts the time into a fraction of the date you can use sometime like this

#CURRENT_DATE_TIME = #CURRENT_DATE + CTIME($CURRENT_TIME)

#ON_TIME = #CURRENT_DATE_TIME + CTIME('000500')

#ON_DATE = INT(#ON_TIME)

#ON_TIME = FRAC(#ON_TIME)

$ON_TIME = CTIME(#ON_TIME)

Hope this is of some help

Steve

### #4

Posted 25 August 2008 - 06:57 PM

So, here we go a third time.

Using 23:55:00 as an example

1) ProIV takes the hour of the day you're interested in 23 and divides that into the number of hours in a day, 24, which gives you .958333333

2) ProIV then takes the minutes and divided that by the number of minutes in a day (60 Minutes in an hour, 24 hours in a day) = 1440, and then adds that to the hour fractional value. In this case, 55 / 1440 = .0381944444 + .958333333 = .9965277777 = The Fractional Representation of 23:55:00

2a) If you had seconds ProIV would do the same thing, but only for the number of seconds in a day 86400.

So, now you have the fractional representation of 23:55:00 and you'd like to add 5 minutes to that and see if by adding 5 minutes to the value rolls you over to a new day. To do that, you add the hour fraction you just calculated above to @DATE, which is already a numerical variable. Using Aug 25, 2008 as an example (@DATE = 76208), you'd get 76208.9965277777 (Aug 25, 2008, 23:55:00 )

Now, you want to add 5 minutes to that value, and see if the new time is in a new Day. So, once again, 5 minutes divided by 1440 (the number of minutes in a day) = .0034722222

Adding that to your saved DateTime numberical variable = 76208.9965277777 + .0034722222 = Midnight ( New @DATE ) = 76209.0000000

I believe that if you make use of @DATE and @TIME as #VARIABLEs instead of $VARIABLES you'll be able to make use of ProIV's ability to to keep track of Dates and Times better than trying it yourself.

HTH,

AK

**Edited by andykay, 25 August 2008 - 07:01 PM.**

**THE LIGHT AT THE END OF THE TUNNEL IS THE HEADLAMP OF THE TRAIN THAT'S ABOUT TO HIT YOU!!!**

# Reply to this topic

#### 0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users