Changing Date Format in TDL

Discussion in 'Tally Developer' started by SAHIL BHATIA, Feb 18, 2019.

    
  1. SAHIL BHATIA

    SAHIL BHATIA New Member


    This is just the extract of the TDL. Full TDL is uploaded in attachment.

    [System: Formula]
    DestPath : ##DestinationPath + "\" + @@DateForm + "\" + @@TimeForm
    CoNumber : $$String:($CompanyNumber:Company:##SVCurrentCompany):5
    DateForm : $$String:$$MachineDate
    TimeForm : @@HrsForm + @@MtsForm
    HrsForm : If $$StringPart:$$MachineTime:0:2 CONTAINS ":" +
    Then $$StringPart:$$MachineTime:0:1 +
    Else $$StringPart:$$MachineTime:0:2
    MtsForm : if $$StringPart:$$MachineTime:0:2 CONTAINS ":" +
    Then $$StringPart:$$MachineTime:2:2 +
    Else $$StringPart:$$MachineTime:3:2


    In this Auto backup TDL, i want to change the date format to YYYY-MMM-DD(2019-Feb-18). Currently the date format is DD-MMM-YYYY(i.e 18-Feb-2019).

    Thanks in advance.
     

    Attached Files:



  2. Amit Kamdar

    Amit Kamdar Administrator Staff Member


    Code:
    $$YYYYMMDDDateFormat:@@DateForm
     
    SAHIL BHATIA likes this.


  3. SAHIL BHATIA

    SAHIL BHATIA New Member


    Which part in the code should be replaced by your code? I'm new to TDL so if you could help, i'd really appreciate.
     


  4. Amit Kamdar

    Amit Kamdar Administrator Staff Member


    Code:
    [System : Formula]
    DateForm : $$String:$$YYYYMMDDDateFormat:$$MachineDate
     


  5. SAHIL BHATIA

    SAHIL BHATIA New Member


    This doesn't seem to work. At the time of creating backup following error shows "Function Backup Function LABEL: Action execution failed!"
     


  6. Amit Kamdar

    Amit Kamdar Administrator Staff Member


    give proper error response..........it would have given you a number in the error message.........
     


  7. SAHIL BHATIA

    SAHIL BHATIA New Member


    Uploaded Error Screenshot
     

    Attached Files:



  8. Amit Kamdar

    Amit Kamdar Administrator Staff Member


    Code:
    [System : Formula]
    DateForm : $$String:$$YYYYMMDDDateFormat:$$MachineDate:"-"
    Use above revised code..............
     
    Neha2017 likes this.


  9. SAHIL BHATIA

    SAHIL BHATIA New Member


    Still same error code is shown. I'm also uploading the updated tdl file for your reference.
     

    Attached Files:



  10. Amit Kamdar

    Amit Kamdar Administrator Staff Member


    It can't be the same error..... update the error screenshot again
     


  11. SAHIL BHATIA

    SAHIL BHATIA New Member


    Here is the error screenshot
     

    Attached Files:



  12. Amit Kamdar

    Amit Kamdar Administrator Staff Member


    No idea beyond this.... you can...for starter...do some R&D in TDE on your own............
     


  13. SAHIL BHATIA

    SAHIL BHATIA New Member


    Well...ok....thanks for your effort
     


  14. rony

    rony Member


    Dear sahil,
    This is 4 ur ref.
    You can change the Date Format using Format attribute at the Field Level. Formats can be Universal Date, Short Date, Long Date, Month Ending, Separator.
    ● Format Universal Date renders date as D-MMM-YYYY i.e., 1-Apr-2010, 11-May-2010, etc.
    ● Format Short Date renders date as D-M-YYYY i.e., 1-4-2010, 11-12-2010, etc.
    ● Format Long Date renders date as Week, D MMM, YYYY i.e., Friday, 31 Dec 2010.
    ● Format Month Ending renders date as MMM YYYY i.e., Dec 2010.
    ● Format Short Date, Separator renders short date with desired separator as D Sep M Sep YYYY i.e., Short Date, Separator:"/" is rendered as 30/4/2010
    For Example :

    ● [#Field: Plain VCH Date
    ● Format : Short Date, Separator:"/"
    Regards
     


  15. SAHIL BHATIA

    SAHIL BHATIA New Member


    I tried this but didn't get it to work. Can you update the above uploaded TDL to make it work like this.

    Thanks in advance
     


  16. rony

    rony Member


    I think U have taken default date format with system formula that why @@ is use instead make date fiekd and in that Use: Universal Date Field. that will work
     


  17. rony

    rony Member


    have u copied TDL from else where or is it urs?
     


  18. rony

    rony Member


    Try 2 change ( DateForm : $$String:$$YYYYMMDDDateFormat:$$MachineDate:"-") 2 DateForm : $$String:$$D-MMM-YYYYDateFormat:$$MachineDate:"-" OR DMMMYYYY
     


  19. SAHIL BHATIA

    SAHIL BHATIA New Member


    I had copied it from somewhere, then I tried to modify it and learning TDL's side by side. Then I got stuck in the date field and came to know about this forum.

    The current file you are looking at is modified according to my need.
     


  20. SAHIL BHATIA

    SAHIL BHATIA New Member


    Tried both, no success. Both show the same error as already uploaded above.

    Also even if they did work, the output format would be DMMMYYYY which won't be of any use to me. I need YYYYMMDD.
     


  21. Amit Kamdar

    Amit Kamdar Administrator Staff Member


    [System : Formula]
    DateForm : $$YYYYMMDDDateFormat:$$MachineDate:"-", 10 : Universal Date
     
    Neha2017 likes this.


  22. SAHIL BHATIA

    SAHIL BHATIA New Member


    Didn't work.....but it gave a weird error which was not like the one received above. Here is the screenshot.
     

    Attached Files:



  23. Amit Kamdar

    Amit Kamdar Administrator Staff Member


    Use it this way..... this will work definitely........

    DateForm : $$String:mad:@DateStr
    DateStr : $$YYYYMMDDDateFormat:$$MachineDate:"-"
     
    SAHIL BHATIA likes this.


  24. SAHIL BHATIA

    SAHIL BHATIA New Member


    Wow......it actually worked. Thank you so much for the effort.

    Could you help me explain a bit about how this worked? The way i understood is that you defined a variable in DateForm and then used formula in that variable itself.
    But when we were trying to do the same thing without the use of variable, it didn't working.
     


  25. Amit Kamdar

    Amit Kamdar Administrator Staff Member


    There is no variable here...... the logic is this.....the reason I do not know......

    Date related functions work singularly..... i.e. it will work like ..... $$YearofDate:$mydate .... but will not work in combined.... like $$String:$$YearofDate:$mydate ...

    So therefore i separated the two.
     
    SAHIL BHATIA likes this.


Share This Page