Jump to content


Photo
- - - - -

CTIME and CDATE Help


6 replies to this topic

#1 motely

motely

    Newbie

  • Members
  • Pip
  • 6 posts

Posted 22 August 2008 - 12:55 PM

I 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

#2 Stephen Morrison

Stephen Morrison

    Newbie

  • Members
  • Pip
  • 1 posts

Posted 22 August 2008 - 04:00 PM

I 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

Dave 


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

#3 andykay

andykay

    ProIV Guru

  • Members
  • PipPipPipPipPip
  • 204 posts
  • Gender:Male
  • Location:Cyberspace...looking for work

Posted 25 August 2008 - 06:25 PM

To further add on Stephen's response...

Time is a decimal representation of the fractional part of the day.

So, using 23:55:00 as an example,

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

#4 andykay

andykay

    ProIV Guru

  • Members
  • PipPipPipPipPip
  • 204 posts
  • Gender:Male
  • Location:Cyberspace...looking for work

Posted 25 August 2008 - 06:57 PM

Man, I hate it when you attempt to edit a wrongful <ENTER> key press, make a long change, and then the edit does not take.

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!!!

#5 motely

motely

    Newbie

  • Members
  • Pip
  • 6 posts

Posted 26 August 2008 - 12:43 PM

Thanks for all the help

#6 motely

motely

    Newbie

  • Members
  • Pip
  • 6 posts

Posted 26 August 2008 - 01:10 PM

Is there a way to take a string '08262008' and convert it to a date?

I have a file edi_on08252008235500.txt and I want to add 5 minutes to this and then get edi_on08262008000000.txt

Is this possible?

#7 motely

motely

    Newbie

  • Members
  • Pip
  • 6 posts

Posted 26 August 2008 - 02:12 PM

I figured it out!

Thanks,
David



Reply to this topic



  


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users