View unanswered posts | View active topics It is currently Thu Dec 25, 2025 1:11 pm



Reply to topic  [ 3 posts ] 
 TWX DateDiff? 
Author Message
Ambassador
User avatar

Joined: Wed Apr 20, 2011 1:19 pm
Posts: 2559
Location: Oklahoma City, OK 73170 US
Unread post TWX DateDiff?
Is there any way to get the elapsed hours/minutes/seconds between two dates in TWX like the VB DateDiff function does?

_________________
Regards,
Micro

Website: http://www.microblaster.net
TWGS2.20b/TW3.34: telnet://twgs.microblaster.net:2002

ICQ is Dead Jim! Join us on Discord:
https://discord.gg/zvEbArscMN


Wed Apr 24, 2013 11:53 am
Profile ICQ YIM WWW
Commander
User avatar

Joined: Tue Oct 07, 2003 2:00 am
Posts: 1133
Location: Augusta, GA
Unread post Re: TWX DateDiff?
I included a FORMAT command in one of the last builds of TWX 2.05, though I'm not sure if it's present in any of the versions floating around. You'll have to try this example to see if it compiles. The syntax is as follows:
format InputVar OutputVar CONSTANT

The constant of interest here is STRTODATETIME, which will convert a date and time value to a real number, representing days elapsed since the beginning of 1900... including the fractional part. So to determine the time elapsed between two string values, you'd do something like this:
Code:
format "4/27/2013 14:20:00" $dateTime1 STRTODATETIME
setVar $now DATE & " " & TIME  \\ date and time are TWX constants
format $now $dateTime2 STRTODATETIME
setPrecision 10
setVar $elapsed ($dateTime2 - $dateTime1)
echo "*Elapsed: " $elapsed

Lines 2 and 3 could be combined, but I've written them this way for clarity. You would need to convert the resulting fractional part to hours, minutes, and seconds if required.

_________________
Claim to Fame: only guy to ever crack the TW haggle algorithm, and fig/shield/hold price formula, twice.


Sat Apr 27, 2013 2:01 pm
Profile WWW
Ambassador
User avatar

Joined: Wed Apr 20, 2011 1:19 pm
Posts: 2559
Location: Oklahoma City, OK 73170 US
Unread post Re: TWX DateDiff?
Works Great... Thanks EP :)

_________________
Regards,
Micro

Website: http://www.microblaster.net
TWGS2.20b/TW3.34: telnet://twgs.microblaster.net:2002

ICQ is Dead Jim! Join us on Discord:
https://discord.gg/zvEbArscMN


Fri May 03, 2013 4:39 pm
Profile ICQ YIM WWW
Display posts from previous:  Sort by  
Reply to topic   [ 3 posts ] 

Who is online

Users browsing this forum: No registered users and 91 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by wSTSoftware.