473,395 Members | 1,624 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Display date as mm/dd/yyyy

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??????
Jul 19 '05 #1
16 2314
"Robin" wrote ...
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

Jul 19 '05 #2
"Robin" <rl*****@energymasterllc.com> wrote in message
news:QO******************@bignews1.bellsouth.net.. .
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


Look into using the DateDiff function:
http://www.devguru.com/Technologies/.../datediff.html

Also, look into using the FormatDateTime Function:
http://www.devguru.com/Technologies/...tdatetime.html

For more on dates...
http://www.aspfaq.com/show.asp?id=2313

Regards,
Peter Foti

Jul 19 '05 #3
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!

"Robin" <rl*****@energymasterllc.com> wrote in message
news:QO******************@bignews1.bellsouth.net.. .
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??????

Jul 19 '05 #4
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)

???????
Jul 19 '05 #5
Ok, if I instead use:
If formatDateTime(date())
It works.

"Robin" <rl*****@energymasterllc.com> wrote in message
news:AO*******************@bignews1.bellsouth.net. ..
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)

???????

Jul 19 '05 #6
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
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jul 19 '05 #7

"Evertjan." <ex**************@interxnl.net> wrote in message
news:Xn********************@194.109.133.29...
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


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

I prefer YYYY/MM/DD as you can sort chronologically on this very easily!
Jul 19 '05 #8
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.
Jul 19 '05 #9
I strongly suggest using YYYYMMDD. It is the only format guaranteed to be
safe in SQL Server.

--
Aaron Bertrand
SQL Server MVP
http://www.aspfaq.com/


"Robin" <rl*****@energymasterllc.com> wrote in message
news:nB*******************@bignews1.bellsouth.net. ..
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.

Jul 19 '05 #10
"Noozer" <po********@127.0.0.1> wrote in message
news:ICq1c.681065$ts4.21511@pd7tw3no...

"Evertjan." <ex**************@interxnl.net> wrote in message
news:Xn********************@194.109.133.29...
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


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

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

easily!

How about ISO-8601?
Basic: YYYYMMDD
Extended: YYYY-MM-DD

Use basic with MS SQL Server and extended with Access. Here are some
articles:
http://aspfaq.com/show.asp?id=2040
http://aspfaq.com/show.asp?id=2214

HTH
-Chris Hohmann

Jul 19 '05 #11
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
"Robin" <rl*****@energymasterllc.com> a écrit dans le message de news:
nB*******************@bignews1.bellsouth.net...
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.

Jul 19 '05 #12
I ended up using :
vd1 = cDate(vd1) + 1
It then reads it as a date and not a string

yay

"Robin" <rl*****@energymasterllc.com> wrote in message
news:nB*******************@bignews1.bellsouth.net. ..
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.

Jul 19 '05 #13
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

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jul 19 '05 #14
"Evertjan." <ex**************@interxnl.net> wrote in message
news:Xn*******************@194.109.133.29...
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


Although you could borrow it from VB.
http://aspfaq.com/2313
Jul 19 '05 #15
Chris Hohmann wrote on 04 mrt 2004 in
microsoft.public.inetserver.asp.general:
"Evertjan." <ex**************@interxnl.net> wrote in message
news:Xn*******************@194.109.133.29...
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


Although you could borrow it from VB.
http://aspfaq.com/2313


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

I wouldn't call that borrowing.

Do you call using jMail borrowing ?
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jul 19 '05 #16
"Evertjan." <ex**************@interxnl.net> wrote in message
news:Xn********************@194.109.133.29...
Chris Hohmann wrote on 04 mrt 2004 in
microsoft.public.inetserver.asp.general:
"Evertjan." <ex**************@interxnl.net> wrote in message
news:Xn*******************@194.109.133.29...
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
Although you could borrow it from VB.
http://aspfaq.com/2313


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


Jul 19 '05 #17

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

Similar topics

4
by: Richard Hollenbeck | last post by:
I'm trying to write some code that will convert any of the most popular standard date formats twice in to something like "dd Mmm yyyy" (i.e. 08 Jan 1908) and compare the first with the second and...
7
by: ziggs | last post by:
How to get date time to display like 01/01/2005 16:14:10? Here's something that I found works against an Oracle database. However, I'm not getting the same results against a SQL 2000 database....
5
by: tsmith81 | last post by:
Ok. I have an ASP page that send data to a database. One of the fields is "Date" (no quotes). The form name is FrontPage_Form1. I would like the Date field to auto populate. So, I did some research...
6
by: Japhy | last post by:
Hello, I am coding a menu using PHP. Selections on the menu have code like : <li> <a href="Updatefindatesedit.php">$fin_name1 $fin_date1 </a></li> <li> <a...
2
by: Benedict Teoh | last post by:
I created a dropdownlist containing day, month and year field and expose a property to assign a date. When I call from a aspx page and assign the value, the new date is not displayed until a submit...
3
by: Marauderz | last post by:
Hello guys, got a little question regarding the regional language settings . Anyway I got a Windows 2003 Server machine that was installed with the date format "dd/MM/yyyy" and location still...
9
by: abctech | last post by:
Helo, I have a calendar on my webpage on which the date format is 'DD-MM-YYYY'; user selects a date and it has to be stored in the same format in the backend; but I checked in MySQL there is...
0
mkozma
by: mkozma | last post by:
Hi, I know there are many articles on this topic but none seem to solve my problem. I have migrated a database (in US format) from SQL server 2005 to DB2 v9. The DB2 needs to work woth Australian...
12
by: petter | last post by:
Hi! I have two questions: one question that regards the COUNT-function, and one about how to display a month even if I don’t have any data for that month. I have an Access database where I want...
1
by: JFKJr | last post by:
Hello everyone, this one might be simple but driving me crazy! Your help will be greatly appreciated. Basically, I created a textbox bound to "Date" field in an Access VBA form. But when the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.