SPONSORS:






User Tag List

Results 1 to 4 of 4
  1. #1
    Member
    Join Date
    Sep 1999
    Posts
    51
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Date arithmatic with Silk

    Any idea if we can do date arithmatic with Silk? In my specific case, I want to compare a file's last modified date and current date, report error if it is older than 1 day. Any tips?

    Thanks

    Sam

  2. #2
    Senior Member
    Join Date
    Jul 1999
    Location
    New York, NY, USA
    Posts
    137
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Date arithmatic with Silk

    Here is some code I wrote a while ago to compare dates that were displayed as a string that does some date math, I think you can modify it to do whaT YOU WANT. BTW there is probably a much easier way to do this that I didn't figure out (at least that what I keep learning from expirience).

    [ ] /***************************************/
    [ ] /***************************************/
    [ ] /* _IsCorrectDate */
    [ ] /***************************************/
    [ ] /* Use this function when you want to */
    [ ] /* compare a string in mm/dd/yy fromat */
    [ ] /* to todays system date +/- a certain */
    [ ] /* number of days. */
    [ ] /* */
    [ ] /* Be sure to pass it the string you */
    [ ] /* want to compare as sDate and the */
    [ ] /* number of days sDate should be from */
    [ ] /* as an INTEGER */
    [ ] /***************************************/
    [-] hidecalls void _IsCorrectDate (STRING sDate, INTEGER iDaysFromToday)
    [ ] // STRINGs for this function which compares
    [ ] // a begin and an end date from two text fields
    [ ] // on a page.
    [ ] STRING sTransformedDate, sDateIn, sDateOut, sRule, sDateValue
    [ ]
    [ ] BOOLEAN bReturn // Return is Valid DATETIME by rules?
    [ ]
    [ ] DATETIME dt = "1900-12-31" //Set to dummy value incase any date in is not
    [ ] //a valid date and dt is not set by function.
    [ ] DATE dDateValue // For type casting DATETIME to DATE which will strip the time
    [ ] // values appended to DATETIME after using AddDateTime function.
    [ ]
    [ ] sDateIn = DateStr () // Todays system date.
    [ ] sDateOut = "unset" // void the variable
    [ ] sRule = "m/d/yy|30|0|0|yyyy-mm-dd|0" // The transformation rule
    [ ] // 00-30 will be in the 21st century.
    [ ]
    [ ] bReturn = TransformDate (sDateIn, sRule, sDateOut, dt) // Here's where we transform the system
    [ ] // date by the rules.
    [ ]
    [ ] dDateValue = [DATE] AddDateTime (dt, iDaysFromToday) // This line adds x Days to the DATETIME value and
    [ ] // casts it to the DATE value (stripping time)
    [ ]
    [ ] sDateValue = ([STRING]dDateValue) //Cast the DATE to a STRING
    [ ]
    [ ] sTransformedDate = "unset" // void the variable.
    [ ] bReturn = TransformDate (sDate, sRule, sTransformedDate, dt) // Here's where we transform the
    [ ] // BeginDate by the rules.
    [-] if ({sTransformedDate} == {sDateValue})
    [ ] print ("")
    [ ] print ("Output from global function _IsCorrectDate")
    [ ] print ("Correct, {sDate} = Todays system date {iDaysFromToday} days.")
    [ ] print ("")
    [ ]
    [-] else
    [ ] print ("")
    [ ] print ("**** Output from global function _IsCorrectDate")
    [ ] LogError ("Date is incorrect, {iDaysFromToday} from todays Date is {sDateValue} not {sTransformedDate}")
    [ ] print ("")
    [ ]
    [ ]

    sorry that this doesn't display with the indentation. I can email or submit a file if someone wants it?


    [This message has been edited by woodman (edited 01-07-2000).]

  3. #3
    Member
    Join Date
    Sep 1999
    Posts
    51
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Date arithmatic with Silk

    Oops! I found Silk's function DiffDateTime which will solve my problem. I guess I was too lazy to search Silk's help before posting my question... ;-)

  4. #4
    Senior Member
    Join Date
    Dec 1999
    Location
    Chicago,Illinois,USA
    Posts
    2,537
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    1 Thread(s)

    Re: Date arithmatic with Silk

    Best way I could think of would just be to write some functions that do this and call them. I am uncertain if SilkTest has built in methods to grab the information you want but the Win32 API does.

    You could get the information that way and then write a calculation based on whatever is returned. You can use an API call like GetFileAttributesA for this.

 

 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

vBulletin Optimisation provided by vB Optimise v2.6.0 Beta 4 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
User Alert System provided by Advanced User Tagging v3.0.9 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Questions / Answers Form provided by vBAnswers (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
vBNominatevBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Feedback Buttons provided by Advanced Post Thanks / Like (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Username Changing provided by Username Change (Free) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
BetaSoft Inc.
Digital Point modules: Sphinx-based search
All times are GMT -8. The time now is 03:55 PM.

Copyright BetaSoft Inc.