Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can't extract Year, Month, Day out of a date

Status
Not open for further replies.

bzeng

Programmer
Dec 11, 2003
13
JP
Hi, due to the different local setting (Date setting) around the world I have to manually create a standard date format for our online database system.(ASP) We prefer to use YYYY/MM/DD. But the hosting server is MM/DD/YYYY.

It works find if I just want to print out the date

<td><%=ProjectDate%> </td>

but when I tried to do
<td><%=year(ProjectDate)&&quot;/&quot;&month(projectdate)&&quot;/&quot;&day(projectdate)%> </td>

it gives me the following error message

Error Type:
Microsoft VBScript runtime (0x800A000D)
Type mismatch
/ZAO/App/Project/Invoice.asp, line 204


However I can do this without a problem

today=year(date())&&quot;/&quot;&month(date())&&quot;/&quot;&day(date())


I have no idea what I did wrong. I have even tried to use Cdate().

the following code works fine

<td><%=Cdate(ProjectDate)%> </td>

however when I add year(), it gives me the same error. (I test it with Year() only this time)

<td><%=Year(Cdate(ProjectDate))%> </td>


What's wrong with my code? or is there a better way to use a standard date format without doing all these complicated manual format.


Thanks in advance





 
Check out faq222-2244 regarding choice of forum. You may do better with your VBScript questions in the VBScript forum forum329

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'If we're supposed to work in Hex, why have we only got A fingers?'
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top