Results 1 to 5 of 5

Thread: VBS - Specify date format

  1. #1

    Thread Starter
    New Member
    Join Date
    Mar 2018
    Posts
    2

    VBS - Specify date format

    Hello guys!
    Im totally new in VBS. I have to do the job for my school. The program must download data from a text file and then automatically specify the date format. The date must be in the text file. For example:
    Name:  zadanie.PNG
Views: 605
Size:  11.0 KB
    Please help me!

  2. #2
    PowerPoster
    Join Date
    Nov 2017
    Posts
    3,116

    Re: VBS - Specify date format

    Aren't there ambiguous formatting possibilities? What if the text file contained:

    "01/03/2018"

    Is it the mm/dd/rrrr format of January 3rd 2018? Or is it the dd/mm/rrrr format of March 1st 2018?

    Unless there are strict guidelines of the possible date formats presented, I'm not sure how code could accurately determine the format just from single date examples.

    That being said, if you had a number of of dates all formatted identically and you needed to determine the single format type they all used, then you could differentiate the date position from the month position once you encounter a value in one position that is > 12. The location of the year position should be trivial to determine, assuming it is consistently presented as 4 digits.

  3. #3

    Thread Starter
    New Member
    Join Date
    Mar 2018
    Posts
    2

    Re: VBS - Specify date format

    My teacher wrote: The program must automatically determine in which format the date is saved. Do you have a code that would do this? I am trying to do something myself, but it does not work for me

  4. #4
    PowerPoster
    Join Date
    Nov 2017
    Posts
    3,116

    Re: VBS - Specify date format

    If you post your code you are much more likely to get help rather than just asking us to write code for you.

  5. #5
    New Member
    Join Date
    Apr 2018
    Posts
    2

    Re: VBS - Specify date format

    <%

    d=CDate("2018-04-16 14:30 ")
    response.write(FormatDateTime(d) & "<br />")
    response.write(FormatDateTime(d,1) & "<br />")
    response.write(FormatDateTime(d,2) & "<br />")
    response.write(FormatDateTime(d,3) & "<br />")
    response.write(FormatDateTime(d,4) & "<br />")

    %>

Posting Permissions

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



Click Here to Expand Forum to Full Width