|
 |
aspx thread: Converting datetime!
Message #1 by "Brandy" <brandmo@h...> on Mon, 12 Feb 2001 09:52:39 +0100
|
|
Hi!
this is not a problem for you who lives in US, but its a nightmare for us..
My problem lay in how to get converted the us datetime which comes from my
database to my regional settings..
The date is written in the database as 1/21/1900, but I want it to be
19/1/2001 on my web page , are there anyone who have a sample of convert
code to help me solve this?
Brandy
Message #2 by "Zhang, Kerwin Yi" <zhangy@m...> on Mon, 12 Feb 2001 17:05:54 +0800
|
|
This message is in MIME format. Since your mail reader does not understand
this format, some or all of this message may not be legible.
------_=_NextPart_001_01C094D3.06FB0BA0
Content-Type: text/plain;
charset="iso-8859-1"
I think you may be just lazy.
Hope this code can help.
Function ConvertDate (InputDate)
Dim ConvDay
Dim ConvMth
Dim ConvYear
ConvDay = Day(InputDate)
ConvMth = ConvertMth(0, InputDate)
ConvYear = Year(InputDate)
ConvertDate = ConvDay & " " & ConvMth & " " & ConvYear
End Function
-----Original Message-----
From: Brandy [mailto:brandmo@h...]
Sent: Monday, February 12, 2001 4:53 PM
To: ASP+
Subject: [aspx] Converting datetime!
Hi!
this is not a problem for you who lives in US, but its a nightmare for us..
My problem lay in how to get converted the us datetime which comes from my
database to my regional settings..
The date is written in the database as 1/21/1900, but I want it to be
19/1/2001 on my web page , are there anyone who have a sample of convert
code to help me solve this?
Brandy
---
http://www.asptoday.com - the leading site for timely,
in-depth information for ASP developers everywhere.
Message #3 by "Kerwin" <zhangy@m...> on Mon, 12 Feb 2001 09:16:21
|
|
Hi,
Try this.
Function ConvertDate (InputDate)
Dim ConvDay
Dim ConvMth
Dim ConvYear
ConvDay = Day(InputDate)
ConvMth = ConvertMth(0, InputDate)
ConvYear = Year(InputDate)
ConvertDate = ConvDay & " " & ConvMth & " " & ConvYear
End Function
> Hi!
>
> this is not a problem for you who lives in US, but its a nightmare for us..
> My problem lay in how to get converted the us datetime which comes from my
> database to my regional settings..
>
> The date is written in the database as 1/21/1900, but I want it to be
> 19/1/2001 on my web page , are there anyone who have a sample of convert
> code to help me solve this?
>
> Brandy
>
Message #4 by "Mike Morris" <mike@v...> on Mon, 12 Feb 2001 17:11:34 +0800
|
|
Hi there
I had the same problem
However I cracked open a 2ltr coke and a couple of sacks of Pringles and
came up with this
Well not really, only one sack of Pringles...
<%
strDate = DatePart("D",rs("fldDate"))
if Len(strDate) = 1 then
strDate = "0" & strDate
end if
strMth = DatePart("M",rs("fldDate"))
if Len(strMth) = 1 then
strDate = strDate & ".0" & strMth
else
strDate = strDate & "." & strMth
end if
strDate = strDate & "." & Right(DatePart("YYYY",rs("fldDate")),2)
response.write strDate
%>
the
results:
if rs("fldDate") was 2/9/01 <-- us format
strDate would produce the result in 09.02.01 <-- rest of the world
I personally wrote to billy gates and said he was a prat but he never
replied
How rude is that bloke??
Cheers
Mike
------------------------------------------------------
Vivid Interactive & Design
200 Wellington Street, Perth
Western Australia 6000
Phone +xxx xxxx xxxx
Facsimile +xxx xxxx xxxx
web http://www.vivid-design.com.au
-------------------------------------------------------
-----Original Message-----
From: Brandy [mailto:brandmo@h...]
Sent: Monday, 12 February 2001 4:53 PM
To: ASP+
Subject: [aspx] Converting datetime!
Hi!
this is not a problem for you who lives in US, but its a nightmare for us..
My problem lay in how to get converted the us datetime which comes from my
database to my regional settings..
The date is written in the database as 1/21/1900, but I want it to be
19/1/2001 on my web page , are there anyone who have a sample of convert
code to help me solve this?
Brandy
Message #5 by Imar Spaanjaars <Imar@S...> on Mon, 12 Feb 2001 10:21:47 +0100
|
|
You want this done in ASP.Net right??
Check out http://aspfree.com/aspdotnet/date.aspx
It describes various ways of date manipulation.
Imar
At 05:05 PM 2/12/2001 +0800, you wrote:
>I think you may be just lazy.
>Hope this code can help.
>
> Function ConvertDate (InputDate)
>
> Dim ConvDay
> Dim ConvMth
> Dim ConvYear
>
> ConvDay = Day(InputDate)
> ConvMth = ConvertMth(0, InputDate)
> ConvYear = Year(InputDate)
>
> ConvertDate = ConvDay & " " & ConvMth & " " & ConvYear
>
> End Function
>
>-----Original Message-----
>From: Brandy [<mailto:brandmo@h...>mailto:brandmo@h...]
>Sent: Monday, February 12, 2001 4:53 PM
>To: ASP+
>Subject: [aspx] Converting datetime!
>
>Hi!
>
>this is not a problem for you who lives in US, but its a nightmare for us..
>My problem lay in how to get converted the us datetime which comes from my
>database to my regional settings..
>
>The date is written in the database as 1/21/1900, but I want it to be
>19/1/2001 on my web page , are there anyone who have a sample of convert
>code to help me solve this?
>
>Brandy
Message #6 by "Brandy" <brandmo@h...> on Mon, 12 Feb 2001 10:45:53 +0100
|
|
should I be laying this code in a kind of text_change event for getting
the date converted before it show up in my textbox then?
Brandy
----- Original Message -----
From: Zhang, Kerwin Yi
To: ASP+
Sent: Monday, February 12, 2001 10:05 AM
Subject: [aspx] RE: Converting datetime!
I think you may be just lazy.
Hope this code can help.
Function ConvertDate (InputDate)
Dim ConvDay
Dim ConvMth
Dim ConvYear
ConvDay =3D Day(InputDate)
ConvMth =3D ConvertMth(0, InputDate)
ConvYear =3D Year(InputDate)
ConvertDate =3D ConvDay & " " & ConvMth & " " & ConvYear
End Function
-----Original Message-----
From: Brandy [mailto:brandmo@h...]
Sent: Monday, February 12, 2001 4:53 PM
To: ASP+
Subject: [aspx] Converting datetime!
Hi!
this is not a problem for you who lives in US, but its a nightmare for
us..
My problem lay in how to get converted the us datetime which comes
from my
database to my regional settings..
The date is written in the database as 1/21/1900, but I want it to be
19/1/2001 on my web page , are there anyone who have a sample of
convert
code to help me solve this?
Brandy
Message #7 by "Brandy" <brandmo@h...> on Mon, 12 Feb 2001 13:45:24 +0100
|
|
thanks Mike your coke and pringles made miracles, and I agree you should
have got response form gates on this one!!
Brandy
----- Original Message -----
From: "Mike Morris" <mike@v...>
To: "ASP+" <aspx@p...>
Sent: Monday, February 12, 2001 10:11 AM
Subject: [aspx] RE: Converting datetime!
> Hi there
>
> I had the same problem
> However I cracked open a 2ltr coke and a couple of sacks of Pringles and
> came up with this
> Well not really, only one sack of Pringles...
>
> <%
> strDate = DatePart("D",rs("fldDate"))
> if Len(strDate) = 1 then
> strDate = "0" & strDate
> end if
> strMth = DatePart("M",rs("fldDate"))
> if Len(strMth) = 1 then
> strDate = strDate & ".0" & strMth
> else
> strDate = strDate & "." & strMth
> end if
> strDate = strDate & "." & Right(DatePart("YYYY",rs("fldDate")),2)
>
>
> response.write strDate
>
> %>
>
> the
>
> results:
>
> if rs("fldDate") was 2/9/01 <-- us format
> strDate would produce the result in 09.02.01 <-- rest of the world
>
> I personally wrote to billy gates and said he was a prat but he never
> replied
> How rude is that bloke??
>
>
> Cheers
>
> Mike
>
>
> ------------------------------------------------------
> Vivid Interactive & Design
> 200 Wellington Street, Perth
> Western Australia 6000
> Phone +xxx xxxx xxxx
> Facsimile +xxx xxxx xxxx
> web http://www.vivid-design.com.au
> -------------------------------------------------------
>
> -----Original Message-----
> From: Brandy [mailto:brandmo@h...]
> Sent: Monday, 12 February 2001 4:53 PM
> To: ASP+
> Subject: [aspx] Converting datetime!
>
> Hi!
>
> this is not a problem for you who lives in US, but its a nightmare for
us..
> My problem lay in how to get converted the us datetime which comes from my
> database to my regional settings..
>
> The date is written in the database as 1/21/1900, but I want it to be
> 19/1/2001 on my web page , are there anyone who have a sample of convert
> code to help me solve this?
>
> Brandy
>
Message #8 by John Pirkey <mailjohnny101@y...> on Mon, 12 Feb 2001 06:47:09 -0800 (PST)
|
|
Since variables are strongly typed - and everything is an object in asp+, try
something like this:
dim dDate As Date
dDate = rs("DateField")
response.write (dDate.format("dd/mm/yyyy", Nothing).tostring())
just a suggestion,
John
--- Brandy <brandmo@h...> wrote:
> thanks Mike your coke and pringles made miracles, and I agree you should
> have got response form gates on this one!!
>
>
> Brandy
> ----- Original Message -----
> From: "Mike Morris" <mike@v...>
> To: "ASP+" <aspx@p...>
> Sent: Monday, February 12, 2001 10:11 AM
> Subject: [aspx] RE: Converting datetime!
>
>
> > Hi there
> >
> > I had the same problem
> > However I cracked open a 2ltr coke and a couple of sacks of Pringles and
> > came up with this
> > Well not really, only one sack of Pringles...
> >
> > <%
> > strDate = DatePart("D",rs("fldDate"))
> > if Len(strDate) = 1 then
> > strDate = "0" & strDate
> > end if
> > strMth = DatePart("M",rs("fldDate"))
> > if Len(strMth) = 1 then
> > strDate = strDate & ".0" & strMth
> > else
> > strDate = strDate & "." & strMth
> > end if
> > strDate = strDate & "." & Right(DatePart("YYYY",rs("fldDate")),2)
> >
> >
> > response.write strDate
> >
> > %>
> >
> > the
> >
> > results:
> >
> > if rs("fldDate") was 2/9/01 <-- us format
> > strDate would produce the result in 09.02.01 <-- rest of the world
> >
> > I personally wrote to billy gates and said he was a prat but he never
> > replied
> > How rude is that bloke??
> >
> >
> > Cheers
> >
> > Mike
> >
> >
> > ------------------------------------------------------
> > Vivid Interactive & Design
> > 200 Wellington Street, Perth
> > Western Australia 6000
> > Phone +xxx xxxx xxxx
> > Facsimile +xxx xxxx xxxx
> > web http://www.vivid-design.com.au
> > -------------------------------------------------------
> >
> > -----Original Message-----
> > From: Brandy [mailto:brandmo@h...]
> > Sent: Monday, 12 February 2001 4:53 PM
> > To: ASP+
> > Subject: [aspx] Converting datetime!
> >
> > Hi!
> >
> > this is not a problem for you who lives in US, but its a nightmare for
> us..
> > My problem lay in how to get converted the us datetime which comes from my
> > database to my regional settings..
> >
> > The date is written in the database as 1/21/1900, but I want it to be
> > 19/1/2001 on my web page , are there anyone who have a sample of convert
> > code to help me solve this?
> >
> > Brandy
> >
=====
----------------------------
John Pirkey
MCSD
John@S...
http://www.stlvbug.org
|
|
 |