473,396 Members | 1,725 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,396 software developers and data experts.

Dates! Dates! Dates!

PW

<rant>

Sorry guys, but I just have to whinge. Dates in ASP are a total pain in the
butt! I seem to get caught out so many times. I realise its my own fault,
but going from the posts in this newsgroup and others, I'm not the only one.
Its just a poorly addressed issue within ASP. So for all your poor buggers
out there that are having problems, particularly with european date formats,
here is my solution.

I have the user enter their date in european format ("31-12-2004") and then
handle it this way ...

myDate = Request.QueryString("txtDate")
myArray = Split(myDate, "-")
myDD = myArray(0)
myMM = myArray(1)
myYYYY = myArray(2)
myISOdate = myYYYY & "-" & myMM & "-" & myDD

I find that ISO formatted dates typically go into the database of choice
pretty readily.

Hope this helps someone.

Cheers,
PW

</rant>
Jul 19 '05 #1
5 2116
PW wrote on 07 aug 2004 in microsoft.public.inetserver.asp.general:
I have the user enter their date in european format ("31-12-2004") and
then handle it this way ...

myDate = Request.QueryString("txtDate")
myArray = Split(myDate, "-")
myDD = myArray(0)
myMM = myArray(1)
myYYYY = myArray(2)
myISOdate = myYYYY & "-" & myMM & "-" & myDD


Usually I also allow for YY, the . and the /, so:

function myISOdate(d)
d = trim(d)
d = replace(d,".","-")
d = replace(d,"/","-")
a = Split(d,"-")
if len(a(2))=2 then a(2) = "20" & a(2)
myISOdate = a(2) & "-" & a(1) & "-" & a(0)
end function

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jul 19 '05 #2
PW wrote on 07 aug 2004 in microsoft.public.inetserver.asp.general:
I have the user enter their date in european format ("31-12-2004") and
then handle it this way ...

myDate = Request.QueryString("txtDate")
myArray = Split(myDate, "-")
myDD = myArray(0)
myMM = myArray(1)
myYYYY = myArray(2)
myISOdate = myYYYY & "-" & myMM & "-" & myDD


Usually I also allow for YY, the . and the /, so:

function myISOdate(d)
d = trim(d)
d = replace(d,".","-")
d = replace(d,"/","-")
a = Split(d,"-")
if len(a(2))=2 then a(2) = "20" & a(2)
myISOdate = a(2) & "-" & a(1) & "-" & a(0)
end function

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jul 19 '05 #3
PW

"Evertjan." <ex**************@interxnl.net> wrote in message
news:Xn********************@194.109.133.29...

Usually I also allow for YY, the . and the /, so:

function myISOdate(d)
d = trim(d)
d = replace(d,".","-")
d = replace(d,"/","-")
a = Split(d,"-")
if len(a(2))=2 then a(2) = "20" & a(2)
myISOdate = a(2) & "-" & a(1) & "-" & a(0)
end function

Hmmm, thats a good idea, except for if the user enters something like
"20/01/60" in which 60 become 2060 insted of 1960.
But I will incorporate that change, thanks. :-)

Jul 19 '05 #4
PW wrote on 08 aug 2004 in microsoft.public.inetserver.asp.general:
if len(a(2))=2 then a(2) = "20" & a(2)


Hmmm, thats a good idea, except for if the user enters something like
"20/01/60" in which 60 become 2060 insted of 1960.


if you want to define that for say 2009/1910:

if len(a(2))=2 and +a(2)<10 then
a(2) = "20" & a(2)
elseif len(a(2))=2 and +a(2)>=10 then
a(2) = "19" & a(2)
end if
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jul 19 '05 #5
It's really not an "ASP" problem. The same issues come up in any programming
environment where the person entering the dates may use a different format
than the system storing the dates. We finally gave up on manually entered
text dates in our system and now use a popup date calendar that always sends
the dates to the web server as "yyyymmdd hh:mm:ss",

--
Mark Schupp
Head of Development
Integrity eLearning
www.ielearning.com
"PW" <pw*@NObigSPAMpond.net.au> wrote in message
news:eI*************@TK2MSFTNGP10.phx.gbl...

<rant>

Sorry guys, but I just have to whinge. Dates in ASP are a total pain in the butt! I seem to get caught out so many times. I realise its my own fault, but going from the posts in this newsgroup and others, I'm not the only one. Its just a poorly addressed issue within ASP. So for all your poor buggers out there that are having problems, particularly with european date formats, here is my solution.

I have the user enter their date in european format ("31-12-2004") and then handle it this way ...

myDate = Request.QueryString("txtDate")
myArray = Split(myDate, "-")
myDD = myArray(0)
myMM = myArray(1)
myYYYY = myArray(2)
myISOdate = myYYYY & "-" & myMM & "-" & myDD

I find that ISO formatted dates typically go into the database of choice
pretty readily.

Hope this helps someone.

Cheers,
PW

</rant>

Jul 19 '05 #6

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

Similar topics

4
by: F | last post by:
Hi I have posted the question few days back about problem in inserting the dates in SQL server and thankful to them who replied. That was solved and this is a nice solution....
24
by: PromisedOyster | last post by:
Is there a way that I can get a resultset that contains unique dates in a given date range without the need to have a temporary table and a cursor? perhaps something like: declare @start_date...
2
by: Trond | last post by:
I have been trying to fig out how to build up an array with dates. When its generated i want to be able to remove duplicate dates. The dates is generated by FileInfo object that is scanning a...
9
by: labelle | last post by:
I have an event listing on my website that is pulling from SQL. Unfortunately, the listing is displaying all events, especially those that are even 2 years old. I want to get rid of them and only...
12
by: Dixie | last post by:
I am trying to calculate the number of workdays between two dates with regards to holidays as well. I have used Arvin Meyer's code on the Access Web, but as I am in Australia and my date format is...
3
by: rugger81 | last post by:
I am currently working in the sql server 2000 environment and I want to write a function to pull all dates within a given date range. I have created several diferent ways to do this but I am...
1
by: pitfour.ferguson | last post by:
My dbase has the start date and end date of each visit. How can I ask Access to list the day of the week of the start (easy), end (easy) and, more importantly, the dates of the visit itself - ie...
3
by: CB Cemetery | last post by:
Hello, I am a student who has developed at database for the Pioneer Cemetery that adjoins our school. I am very inexperienced with Access. I use an input mask to add burial dates mm/dd/yyyy. The...
3
by: myemail.an | last post by:
If I need to format how the content of a field is displayed, I can click ALT + ENTER from design view, and specify the format, for example, the number of decimal digits and so on. Is there a way...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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...
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...
0
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...

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.