Display date as mm/dd/yyyy

R

Robin

I have a variable that is set to:
vD1 = 2004/1/1
vD2 = 2004/1/15

I am doing an if/then that looks to see if date() is > vD2. If so then
response.write vD1 & " to " & vD2
When I write out the variables, it is giving me the numeric value of these
dates:
334 to 105.473684210526

How can I convert these values to either yyyy/mm/dd or dd/mm/yy??????
 
R

Rob Meade

...
I have a variable that is set to:
vD1 = 2004/1/1
vD2 = 2004/1/15

With ASP or are you picking these up from a database?

If you are using 'exactly' the above you'd actually be doing a mathematical
equasion :

2004 divided by 1 divided by 1 etc
How can I convert these values to either yyyy/mm/dd or dd/mm/yy??????

Please advise as to the above.

Regards

Rob
 
R

Robin

I guess I just really need to learn more about date's in sql/asp.
I tried setting the variables to "01/01/2004" and to "2004/01/01", but those
are read as text strings and can't really be used to compare to a date.
I'll read up more. Thanks!
 
R

Robin

Ok, barely wiser and still confused. This is the code:
vD1 = FormatDateTime("1/6/2004")
vD2 = FormatDateTime("1/19/2004")
If date() > vD2 Then
response.write "<option value='" & vD1 & "-" & vd2 & "'>" & vd1 & " to
" & vd2 & "</option></select>"
End If


the "If" is finding that date() is not > vD2
(date() = 3/3/2004; vD2 = 1/19/2004)

???????
 
E

Evertjan.

Robin wrote on 03 mrt 2004 in microsoft.public.inetserver.asp.general:
vD1 = FormatDateTime("1/6/2004")

You should not use this, as the date 1/6/2004 can mean 2 different dates.

To me it is the first of June!

Always use "2004/1/6" =sixth of January
or "2004/6/1" =first of June
 
N

Noozer

Evertjan. said:
Robin wrote on 03 mrt 2004 in microsoft.public.inetserver.asp.general:


You should not use this, as the date 1/6/2004 can mean 2 different dates.

To me it is the first of June!

Always use "2004/1/6" =sixth of January
or "2004/6/1" =first of June

I with the world would move to one standard...

I prefer YYYY/MM/DD as you can sort chronologically on this very easily!
 
R

Robin

I did convert to yyyy/mm/dd as MySQL uses that format also. Now here's (yet
another) question regarding dates ...
I'm just testing this out but it's not working.
vDate = date()
(vDate = 2004/3/3)
vTomorrow = vDate + 1
(vTomorrow = 2004/3/4)

Ok. That's how the above is working and all is fine. Now, if I do this:

vD1 = formatDateTime("2004/1/1")
(vD1 = 2004/1/1)
vD2 = vD1 + 1
I get this error: Type mismatch: '[string: "1/1/2004"]'

So, I guess it's not really seeing vD1 as a date type.
 
A

Aaron Bertrand [MVP]

I strongly suggest using YYYYMMDD. It is the only format guaranteed to be
safe in SQL Server.
 
H

Himselff

You can always analyse each section of ure string with mid, left and right
function , which mean that if u grab a date whit

MaDate = Format$(Date$, "yyyy/mm/dd")

left(MaDate,4) = year etc ...

so u can grab any piece and add wath u want or validate !

=)


--
*****************************************
Plus de café ? Trop de travail ?
Bloqué ? Désesperé ?
Va prendre l'air, fumer une cigarette,
Sa fonctionne a tout coup =)
****************************************************
Fred

www.dmsinc.ca
 
R

Robin

I ended up using :
vd1 = cDate(vd1) + 1
It then reads it as a date and not a string

yay
 
E

Evertjan.

Himselff wrote on 03 mrt 2004 in
microsoft.public.inetserver.asp.general:
You can always analyse each section of ure string with mid, left and
right function , which mean that if u grab a date whit

MaDate = Format$(Date$, "yyyy/mm/dd")

left(MaDate,4) = year etc ...

No you cannot.

Format() does not exist in ASP VBS
 
C

Chris Hohmann

Evertjan. said:
Chris Hohmann wrote on 04 mrt 2004 in
microsoft.public.inetserver.asp.general:


No, then you would have to install something (VB6).

You also have to install something to use jMail, ADO, MSXML, CDO, OWC or
anything else that is not built into ASP. It's unclear how that negates
my original assertion that one can borrow the formatting capabilities
available in VB6. Also note that only the MSSTDFMT.DLL library needs to
be installed, not MS Visual Basic 6.0

I wouldn't call that borrowing.

You are free to call it whatever you like.

Do you call using jMail borrowing ?

I don't use jMail, but if I did then yes I would call that borrowing.


-Chris Hohmann
 

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

Forum statistics

Threads
474,262
Messages
2,571,052
Members
48,769
Latest member
Clifft

Latest Threads

Top