473,385 Members | 2,269 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,385 software developers and data experts.

asp date format question

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
Jul 22 '05 #1
3 1431
"Lin Ma" <a@a.com> wrote in message
news:#l**************@TK2MSFTNGP15.phx.gbl...
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.
Jul 22 '05 #2
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!
Jul 22 '05 #3
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.
Jul 22 '05 #4

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

Similar topics

15
by: Simon Brooke | last post by:
I'm investigating a bug a customer has reported in our database abstraction layer, and it's making me very unhappy. Brief summary: I have a database abstraction layer which is intended to...
4
by: peashoe | last post by:
I have an asp page that uses a calendar.js (pop-up) file to add an exact date format in the text field (txtDDate). My problem is I need some javascript that sets an alert that does not allow them...
6
by: Dario Di Bella | last post by:
Hi all, we have the following urgent issue affecting our development team. Initially we had one particular workstation that failed executing queries on a DB2 database, raising an invalid date...
20
by: andreas | last post by:
When I copy a vb.net project using date formats from one PC with a windows date format f.e. dd/mm/yyyy to another PC having a format yy/mm/dd then I get errors. How can I change for a while in the...
2
by: syntego | last post by:
We commonly use triggers to log changes to our main tables to historical log tables. In the trigger, we create a concatenated string of the old values by casting them as follows: ...
10
by: ARC | last post by:
Hello all, General question for back-end database that has numerous date fields where the database will be used in regions that put the month first, and regions that do not. Should I save a...
9
by: Martin | last post by:
I'm retrieving some records from a database. One of the fields contains a date/time. I would like to format it as I send it out to the table in the displayed page. Can some one please tell me...
5
Stang02GT
by: Stang02GT | last post by:
I have been asked to validate a date on our web-page so that people cannot enter dates like 14/1/08 or 2/30/06. I have found code that will do exactly what i need it to do, but i am not sure how to...
6
by: Mtek | last post by:
Hi, We have a form where the user selects a date from a calendar, the date is in the format May 23, 2008. The date in the datebase is in the format 05212008. What we need to do is get the...
4
by: OzNet | last post by:
I have some functions to calculate the working days in a given period. This includes a table that is queried to calculate the number of public holidays that don’t occur on a weekend. If I test...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...
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
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,...

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.