Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Controlling date format when writing to a file

Posted on 2003-03-29
6
Medium Priority
?
148 Views
Last Modified: 2010-05-01
Hi,

I have a date variable called

TimeOfArrival that contains #3:57:00 PM#

If I do debug.print I get: 3:57:00 PM

which is good.

But when I write it to a text file I get:     #1899-12-30 15:57:00#  which is not good.
What I want to get when I write to file is:   #3:57:00 PM#

Any help apprecitated greatly,

Jon
0
Comment
Question by:jonleehacker
  • 3
  • 2
6 Comments
 
LVL 3

Accepted Solution

by:
DeAn earned 400 total points
ID: 8232275
try:

Format(TimeOfArrival, "h:mm:ss AMPM")
0
 

Expert Comment

by:narang
ID: 8232319
Salut!

   To solve your problem you just have to format your hour before writing it into the file :

In VB6
  Format(TimeOfArrival , "HH:MM:SS AM/PM")

In VB.NET
  Format(TimeOfArrival , "HH:MM:SS tt")

I hope that it will help,
Have a nice day or evening ;+)
Narang
0
 
LVL 3

Expert Comment

by:DeAn
ID: 8232350
Format(TimeOfArrival, "h:mm:ss AMPM") returns: 3:57:00 PM

leave out an "h" in the format
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 1

Author Comment

by:jonleehacker
ID: 8232617
Thank you,

Works like a charm!!!!
0
 
LVL 1

Author Comment

by:jonleehacker
ID: 8255775
Actually I just checked again and those solutions don't work. They format it correctly but because the format function returns a string and I am writing to file I get:
"3:57:00 PM"

rather than #3:57:00 PM# which is what I need to maintain the datatype in the file.
0
 
LVL 1

Author Comment

by:jonleehacker
ID: 8256046
I figured it out. Here's the correct method:

Write #2, ;

Print #2, "#" & CntClient.TimeOfArrival & "#,";

Write #2,
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

569 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question