date formatting question--quick one

M

middletree

I know I could write one, but is there a built-in VBScript/ASP function to
take a date, which is in the format mm/dd/yyyy, and put it in a yymmdd
format?
 
R

Ray at

No, vbscript doesn't have a function for everything like that pansy php
language. :]


Function BetterDate()
Dim sDate
sDate = Date
BetterDate = Right(Year(sDate), 2) & Right("0" & Month(sDate), 2) &
Right("0" & Day(sDate), 2)
End Function

Response.Write BetterDate

You may want to conder yyyy over yy though.

Ray at home
 
M

middletree

thanks!

Gotta have the yy, because the boss has a special request.

Ray at said:
No, vbscript doesn't have a function for everything like that pansy php
language. :]


Function BetterDate()
Dim sDate
sDate = Date
BetterDate = Right(Year(sDate), 2) & Right("0" & Month(sDate), 2) &
Right("0" & Day(sDate), 2)
End Function

Response.Write BetterDate

You may want to conder yyyy over yy though.

Ray at home


middletree said:
I know I could write one, but is there a built-in VBScript/ASP function to
take a date, which is in the format mm/dd/yyyy, and put it in a yymmdd
format?
 
F

Foo Man Chew

Gotta have the yy, because the boss has a special request.

Tell the boss the stone age is over. It's time to remember the mentality
that caused the Y2K problem in the first place, and a similar mentality that
gives people fits trying to figure out if 03/04/02 is March 4, 2002, or
April 3, 2002, or April 2, 2003, or Feb. 4, 2003.
 
B

Bob Barrows

Foo said:
Tell the boss the stone age is over. It's time to remember the
mentality that caused the Y2K problem in the first place, and a
similar mentality that gives people fits trying to figure out if
03/04/02 is March 4, 2002, or April 3, 2002, or April 2, 2003, or
Feb. 4, 2003.

Ease up will ya? He did not say he wanted to store the dates this way,
merely display them (I think). It's not as if it was even possible to store
them with this format (unless the mistake of using a text field to store
them was being made.)

Bob Barrows
 
B

Bob Lehmann

If you are getting the date from an Access DB you could format it in the
query..

SELECT FORMAT(event_date,'mm/dd/yy') AS EventDate etc, etc...

Bob Lehmann
 
M

middletree

Good night, but you're presumptive and rude!

If you must know, I am creating folders, based on which date some support
files were sent, I have been asked to put files into folders with a format
of yymmdd, so if I wanted to see the trace files that were sent in regards
to Ticket 1001, on Dec 24, I'd just go to \\servername\tickets\1001\0312124
 
M

middletree

And for the record, our company makes software used for deposits and
withdrawals in 15 of the 30 largest banks in the world, so you can be sure
that we have a handle on the Y2K issue.
 
F

Foo Man Chew

Ease up will ya? He did not say he wanted to store the dates this way,
merely display them (I think). It's not as if it was even possible to store
them with this format

Obviously not. Of course, my problem with the confusion caused by
non-standard date formats has nothing to do with storage, but rather with
interpretation (both in passing them to and from a database, between
software, etc., and display to humans).
 
F

Foo Man Chew

of yymmdd, so if I wanted to see the trace files that were sent in regards
to Ticket 1001, on Dec 24, I'd just go to
\\servername\tickets\1001\0312124

And what's wrong with this:

\\servername\tickets\1001\20031224\

....other than it's much more clear to *anyone* (not just the author of the
software) what the date actually is.
 
F

Foo Man Chew

And for the record, our company makes software used for deposits and
withdrawals in 15 of the 30 largest banks in the world, so you can be sure
that we have a handle on the Y2K issue.

Save it. I was making an analogy, not accusing you of being dumb about Y2K.
 
M

middletree

Don't tell me what to save.

And saying that my boss is in the stone age IS an accusation of being dumb.
 
M

middletree

I asked a question about how to do something. Any comments or info you can
share which will help me are not. The kind of comments you did offer are
not. It is not for you to decide how I should name our folders.
 
F

Foo Man Chew

I asked a question about how to do something.

And I'm just trying to understand the advantage of using 2-digit years. You
have shown me nothing substantial, so I'll assume you don't have a good
reason.
 
B

Bob Barrows

middletree said:
I asked a question about how to do something. Any comments or info
you can share which will help me are not. The kind of comments you
did offer are not. It is not for you to decide how I should name our
folders.
Drop it middletree. You may as well get used to it now. There is no way to
control the behavior of others in newsgroups. By posting a question here,
you are going to get a great assortment of response, some of which you may
not like. Deal with it. It is the nature of the medium. People are free to
reply in whatever manner they deem fit, and they are free to offer
unsolicited advice. And not only are they free to do so, they WILL do so.

Moreover, you should welcome it. If we were somehow restricted to only
providing the answers to the questions being asked, without adding extra
advice about things that we perceive to be problem areas, I do not think we
would be of as much help as I like to think we are.

Bob
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,680
Members
48,796
Latest member
Greg L.

Latest Threads

Top