Vb Script change none date time value to valid date time


My script reads a text file that contains a datetime. Within the script I have a varible called strFieldData whch stores a datetime value.

Sometimes 99.99.99<2 white spaces>99:99:99 (date time) has been entered which is not valid date and time for the program that recieves this value.

I tried to convert this value using the Now function but its still keeping the same value:

If strFieldData = "99.99.99  99:99:99" then
                     strFieldData = Now
Still returns 99.99.99  99:99:99

Is there another way i can conert this value to the server date time?
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ste5anSenior DeveloperCommented:
Post your complete script and the sample data text file. It seems that you If condition is not correct. E.g. number of spaces. Maybe there are trailing or leading spaces. Or milliseconds.
Saurabh Singh TeotiaCommented:
Can you try this...

if instr(1,strFieldData,"99.99.99  99:99:99",vbTextCompare) >0 then
  strFieldData = Now

Open in new window

Bill PrewIT / Software Engineering ConsultantCommented:
Perhaps there are leading or training spaces, which TRIM() could remove.  Another thought would be that the 2 white space characters you are seeing in the middle aren't actually spaces, but maybe a tab character being expanded in your editor, etc.

If Trim(strFieldData) = "99.99.99  99:99:99" Then strFieldData = Now

Open in new window


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
VB Script

From novice to tech pro — start learning today.