-
Mar 30th, 2018, 08:17 AM
#1
Thread Starter
New Member
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:
Please help me!
-
Mar 30th, 2018, 08:56 AM
#2
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.
-
Mar 31st, 2018, 06:38 AM
#3
Thread Starter
New Member
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
-
Mar 31st, 2018, 08:49 AM
#4
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.
-
Apr 12th, 2018, 04:12 AM
#5
New Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|