Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > asp date format question

Reply
Thread Tools

asp date format question

 
 
Lin Ma
Guest
Posts: n/a
 
      04-12-2005
In my asp page, I have a date value from SQL database and I would like to be
formatted like: yyyy,mm,dd.

Such as 1/22/2005 to be 2005,1,22

Is there a simple command I can use?

Thanks,


Lin


 
Reply With Quote
 
 
 
 
McKirahan
Guest
Posts: n/a
 
      04-12-2005
"Lin Ma" <> wrote in message
news:#...
> In my asp page, I have a date value from SQL database and I would like to

be
> formatted like: yyyy,mm,dd.
>
> Such as 1/22/2005 to be 2005,1,22
>
> Is there a simple command I can use?
>
> Thanks,
>
>
> Lin


Will this help? Watch for word-wrap.

strDAT = { your SQL database date }

strDAT = DatePart("yyyy",strDAT) & "," & DatePart("d",strDAT) & "," &
DatePart("m",strDAT)

Note that "mm/dd/yyyy" format may be confusing and that "yyyy/mm/dd" is
preferred.


 
Reply With Quote
 
 
 
 
dlbjr
Guest
Posts: n/a
 
      04-12-2005
Just for fun and faster

Function MyDateFormat(d)
a = Split(d,"/")
If IsArray(a) Then
MyDateFormat = a(2) & "," & a(0) & "," & a(1)
End If
End Function

'dlbjr
'Pleading sagacious indoctrination!


 
Reply With Quote
 
Dave Anderson
Guest
Posts: n/a
 
      04-13-2005
Lin Ma wrote:
> In my asp page, I have a date value from SQL database and I would
> like to be formatted like: yyyy,mm,dd.
>
> Such as 1/22/2005 to be 2005,1,22


That is not an example of yyyy,mm,dd format, as you are suppressing leading
zeroes.



> Is there a simple command I can use?


If you *really* want yyyy,mm,dd format, then you could let SQL do it, for
one thing. Using date format 102, you can force the output into yyyy.mm.dd,
then replace '.' with ',':

SELECT REPLACE(CONVERT(CHAR(10),GETDATE(),102),'.',',')

http://msdn.microsoft.com/library/en...ca-co_2f3o.asp
http://msdn.microsoft.com/library/en...ra-rz_76lh.asp



--
Dave Anderson

Unsolicited commercial email will be read at a cost of $500 per message. Use
of this email address implies consent to these terms. Please do not contact
me directly or ask me to contact you directly for assistance. If your
question is worth asking, it's worth posting.


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Date, date date date.... Peter Grison Java 10 05-30-2004 01:20 PM
Date Format - best way of converting a string into a date format Brian Candy ASP .Net 2 02-18-2004 02:13 PM
Given a date, how to find the beginning date and ending date of that week Matt ASP .Net 1 11-08-2003 09:14 PM
Given a date, how to find the beginning date and ending date of that week Matt C Programming 3 11-08-2003 09:07 PM
Given a date, how to find the beginning date and ending date of that week Matt C++ 2 11-08-2003 08:30 PM



Advertisments