473,621 Members | 2,745 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Small question?

I've almost completed my little application for work. This weekend I've been
working on Streams so I can write a logfile showing the work that was
accomplished. Wanting to make each logfile programmaticall y unique, I
decided to include the date that the log was written as a part of it's
filename. I was looking through all of the date stuff and all the posts
about formatting and was wondering how in the world I was going to get all
of that in a sub the way I wanted. I was searching for a way to format JUST
the date and ran into the 'DateString' method. It gave me exactly what I was
looking for without a lot of extra work, but I was wondering... and here's
the question... is there something substandard with this method? In the
newsgroup here I've seen folks wanting JUST a date and the answers have
really been strong on formatting, which the DateString doesn't require.
Dec 26 '06 #1
16 1502
"Bruce W. Darby" <kr****@comcast .netwrote in
news:ZI******** *************** *******@comcast .com:
I've almost completed my little application for work. This weekend
I've been working on Streams so I can write a logfile showing the work
that was accomplished.
Have you taken a look at Log4Net or Microsoft's Enterprise logging blocks?
>I've seen folks wanting JUST a date and the answers have really been
strong on formatting, which the DateString doesn't require.
What a rambling post - have you taken a look at now().ShortDate ? That
formats the date to the local regional settings.

Otherwise you can use the FormatDateTime command specify your own format.

Dec 26 '06 #2
Bruce,

I did not knew this function. Not so strange:. if I understand it well, than
it is outside the USA completely useless.

In my idea is this construction beneath the nicest for your purpose

Dim mylogfiledate As String = Now.ToString("y yyyMMddhhmmss")
I hope this helps,

Cor

"Bruce W. Darby" <kr****@comcast .netschreef in bericht
news:ZI******** *************** *******@comcast .com...
I've almost completed my little application for work. This weekend I've
been working on Streams so I can write a logfile showing the work that was
accomplished. Wanting to make each logfile programmaticall y unique, I
decided to include the date that the log was written as a part of it's
filename. I was looking through all of the date stuff and all the posts
about formatting and was wondering how in the world I was going to get all
of that in a sub the way I wanted. I was searching for a way to format
JUST the date and ran into the 'DateString' method. It gave me exactly
what I was looking for without a lot of extra work, but I was wondering...
and here's the question... is there something substandard with this
method? In the newsgroup here I've seen folks wanting JUST a date and the
answers have really been strong on formatting, which the DateString
doesn't require.

Dec 26 '06 #3
The first thing that you need to remember, Bruce, is that the DateString
function does not return a Date. Instaed it returns a string that represents
the current Date formatted as MM-dd-yyyy.

This is the same value that is returned by
DateTime.Today. ToString("MM-dd-yyyy") and also
DateTime.Now.To String("MM-dd-yyyy"). If your Regional Short Date setting is
set to MM-dd-yyyy then the same value is also returned by
DateTime.Today. ToString("d") and DateTime.Now.To String("d").

If all you will ever need is the date in MM-dd-yyyy fomat then fine, but the
multitude of date formatting options provides you with so many more options.

As to log files, the questions you need to ask yourself include:

1. Will the program write a new logfile each time it runs?

2. Will the program run multiple times in any one day?

3. Will the log files need to be accessed by anyone else apart from me?

If (1) is true and (2) is true then you're going to run into problems
because subsequent runs in the same day will overwrite the log files from
previous runs on that day.

If (3) is true then the naming convention for the log files must be such
that they know, unambiguously, what it is they are looking at, i.e. when the
file is named 01-02-2007.log, they must be absolutely aware that the file
relates to the 2nd of January and not the 1st of February.

I use log files extensively, not only to log critical activity, but also for
diagnostic information.

When I am using a new log file for each day, the naming convention I use is
yyyyMMdd.log and everybody who has to deal with such file knows that the
name is in that format.

When I am using a new log file for each month, the naming convention I use
is yyyyMM.log and, again, everybody who has to deal with such file knows
that the name is in that format.

The most important thing is to be absolutely consistent with what you do. If
you chop and change then you will end up confusing yourself.
"Bruce W. Darby" <kr****@comcast .netwrote in message
news:ZI******** *************** *******@comcast .com...
I've almost completed my little application for work. This weekend I've
been working on Streams so I can write a logfile showing the work that was
accomplished. Wanting to make each logfile programmaticall y unique, I
decided to include the date that the log was written as a part of it's
filename. I was looking through all of the date stuff and all the posts
about formatting and was wondering how in the world I was going to get all
of that in a sub the way I wanted. I was searching for a way to format
JUST the date and ran into the 'DateString' method. It gave me exactly
what I was looking for without a lot of extra work, but I was wondering...
and here's the question... is there something substandard with this
method? In the newsgroup here I've seen folks wanting JUST a date and the
answers have really been strong on formatting, which the DateString
doesn't require.

Dec 26 '06 #4
BTW Bruce, small questions have a habit of becoming big questions :)
"Bruce W. Darby" <kr****@comcast .netwrote in message
news:ZI******** *************** *******@comcast .com...
I've almost completed my little application for work. This weekend I've
been working on Streams so I can write a logfile showing the work that was
accomplished. Wanting to make each logfile programmaticall y unique, I
decided to include the date that the log was written as a part of it's
filename. I was looking through all of the date stuff and all the posts
about formatting and was wondering how in the world I was going to get all
of that in a sub the way I wanted. I was searching for a way to format
JUST the date and ran into the 'DateString' method. It gave me exactly
what I was looking for without a lot of extra work, but I was wondering...
and here's the question... is there something substandard with this
method? In the newsgroup here I've seen folks wanting JUST a date and the
answers have really been strong on formatting, which the DateString
doesn't require.

Dec 26 '06 #5

"Spam Catcher" <sp**********@r ogers.comwrote in message
news:Xn******** *************** ***********@127 .0.0.1...
"Bruce W. Darby" <kr****@comcast .netwrote in
news:ZI******** *************** *******@comcast .com:
Have you taken a look at Log4Net or Microsoft's Enterprise logging blocks?
Actually, no, I haven't. :) I'm working this little tool up myself on my own
time for work so I can extend my understanding of programming and the .Net
environment. As such, I look at what is avail 'at the time'. Would I require
the Enterprise version of VS2995 to use the logging blocks? As it is, I only
have the Standard Edition.
What a rambling post - have you taken a look at now().ShortDate ? That
formats the date to the local regional settings.

Otherwise you can use the FormatDateTime command specify your own format.
Sorry for rambling, but I just wanted to provide some data that I wasn't
sure was widely known.
Dec 26 '06 #6
I did not knew this function. Not so strange:. if I understand it well,
than it is outside the USA completely useless.
I didn't see any warnings that it would not be useful outside the United
States. Perhaps it's a method that is much the same as the 'Shortdate'
method SpamCatcher mentioned.
In my idea is this construction beneath the nicest for your purpose

Dim mylogfiledate As String = Now.ToString("y yyyMMddhhmmss")
I hope this helps,
Thanks for the formatting string above, Cor. If you didn't want the hours,
minutes, seconds, I take it that you just don't include them in the
formatting string? I'll keep it in mind, but what I was actually doing is
concatenating the date into the file path, as in...

Dim strFullFilename As String = strPathName & "\" & DateString &
[filename.ext]

DateString returns a string formatted as 12-25-2006, which worked perfectly
for what I needed.

When I attempted to use another Date format, the slashes in the date were
interpreted as directory seperators and it created a directory structure
where12 was its own directory with a subdirectory of 25, etc.

I'm learning... thanks for your input!
Dec 26 '06 #7
As to log files, the questions you need to ask yourself include:
>
1. Will the program write a new logfile each time it runs?
Yes. :)
2. Will the program run multiple times in any one day?
EXTREMELY doubtful
3. Will the log files need to be accessed by anyone else apart from me?
The VP probably. We're a small company with 5 employees, so it's me or him.
LOL I've included a sample of the actual filename syntax in my response to
Cor. I wanted to make absolutely certain that my logfiles were descriptive
AND unique. I anticipate having to run the utility about once a week at the
most, so this naming system should suffice quite nicely. If it needs to be
changed at a later date, I can do a revision quickly. And I can totally
understand the communication issues and the need to be consistent. Thanks
again.


Dec 26 '06 #8
>. Would I require the Enterprise version of VS2995 to use the logging
>blocks?
Sorry, meant 2005... FAT FINGERS!!!
Dec 26 '06 #9
Bruce,

If I have read it well, than DateString returns forever a MM dd yy format.
That format is only used in the USA and some Coca Cola cultures, (Think
about Japan when they are not using their own figurs but not on China). You
would believe that Canada had the same as the USA, but they have it like
England and I thought a more sophisticated way (not like France)..

You can see that it is confusing as Stephany shows. See always thinks that
more people know about those very different culture differences when writing
date and time. (it is not only the date it is as well with times), in my
idea are it only a few.

Somebody wrote ones in this newsgroup. I live in Australia, we will never
use American software because it gives always troubles with dates (Australia
has the same time standards as the USA). I assume that he meant with we his
company, before I get some responses from Stephany.

(I gave the full string, like Stephany I did not know how many times a day
you would write a log file, beside that is the ISO way better when you do a
Dir in your log directory).

Cor
"Bruce W. Darby" <kr****@comcast .netschreef in bericht
news:2L******** *************** *******@comcast .com...
>I did not knew this function. Not so strange:. if I understand it well,
than it is outside the USA completely useless.

I didn't see any warnings that it would not be useful outside the United
States. Perhaps it's a method that is much the same as the 'Shortdate'
method SpamCatcher mentioned.
>In my idea is this construction beneath the nicest for your purpose

Dim mylogfiledate As String = Now.ToString("y yyyMMddhhmmss")
I hope this helps,

Thanks for the formatting string above, Cor. If you didn't want the hours,
minutes, seconds, I take it that you just don't include them in the
formatting string? I'll keep it in mind, but what I was actually doing is
concatenating the date into the file path, as in...

Dim strFullFilename As String = strPathName & "\" & DateString &
[filename.ext]

DateString returns a string formatted as 12-25-2006, which worked
perfectly for what I needed.

When I attempted to use another Date format, the slashes in the date were
interpreted as directory seperators and it created a directory structure
where12 was its own directory with a subdirectory of 25, etc.

I'm learning... thanks for your input!

Dec 26 '06 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
3936
by: Randall Parker | last post by:
Using IE 6.x (whatever is the latest) on Windows 2000. For these two CSS definitions if I remove the 2 lines that have the "mso-" font family definitions (mso-fareast-font-family, and mso-bidi-font-family) then the "SmallerText" assigned as a class to a div tag produces larger text than the "SmallerText2". So x-small is treated as a bigger font size than plain old small. How the heck is one supposed to know all the MS stuff one needs...
7
1258
by: Sharon | last post by:
Hiya I have a small question, I saw this piece of code somewhere (it's for creating a customized context menu) and I was wondering: Why is it that the STYLE and SCRIPT-tags are broken up into parts? I hope someone can answer my question, thanks! Sharon html+='<TABLE STYLE="border:1pt solid #808080" BGCOLOR="#CCCCCC" WIDTH="140" HEIGHT="220" CELLPADDING="0" CELLSPACING="1">'; html+='<ST'+'YLE TYPE="text/css">\n'; html+='a:link...
3
1983
by: Tim | last post by:
Hi Group, Apologies if this is a bit OT (if so, please advise where it should be posted). I was wondering if anyone had any ideas as to what applications could work in a system where the server has a large storage and fast processing speed, but the client is connected via a small bandwidth? Assuming many clients could be connected simultaneously.
5
1976
by: Geoff Cox | last post by:
Hello Would be grateful if someone can make a few things clear for me! I have developed a small app using Java and would like to do the same using C++ but without the need for a runtime environment addition. This is a very samm app and it seems foolish to have to ask the user to install 20 MB of extra software. The app displays an image and a question asks the user to indicate
1
1239
by: Gena | last post by:
Hi , I'm a newbe to programming and have a small question: I made a small program with a class. in the class's header file I have : double *ptr_output; Void main() { double result;
4
2040
by: =?Utf-8?B?VzFsZDBuZTc0?= | last post by:
When one architects a new project one of the first steps in the decision is to decide on the layers. (In my opinion anyway) One architecture that I have used before is to go solid OO and create objects, which normally are very small and only deals with the stuff pertaining to that object, then break it down into Business Process, Process Controllers and Data Access Objects for each "Object", each of which is created in it's very own .Net...
1
2478
by: =?Utf-8?B?cmJiZW5zb24=?= | last post by:
To begin,, the network infactructure- Servers - Server00 - Windows Server 2003/Installed Server01 - Windows Server 2003/plan to install Server10 - Linux RedHat Workstation/Installed Client/Workstations - Client 00 - Windows XP Pro/Installed Client 01 - Windows XP Home/Installed
169
9045
by: JohnQ | last post by:
(The "C++ Grammer" thread in comp.lang.c++.moderated prompted this post). It would be more than a little bit nice if C++ was much "cleaner" (less complex) so that it wasn't a major world wide untaking to create a toolchain for it. Way back when, there used to be something called "Small C". I wonder if the creator(s) of that would want to embark on creating a nice little Small C++ compiler devoid of C++ language features that make...
4
3659
by: ATS16805 | last post by:
Hi. I wonder if it's possible to "force" a browser to "switch to SSR mode" for any given document. Specifically, I'm looking for a solution, not to a User Agent issue (i think), but a coding idea; a programming "what if..?". i'm not concerned w/ manipulating a browser (i.e. prefs., settings this URL, always view SSR, save), but rather something i would code into the document which would request the browser to display in this mode (i.e....
0
8653
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8597
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8457
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7127
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5554
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4150
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2587
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1763
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1460
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.