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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Date question

Status
Not open for further replies.

bongmarley

Programmer
Oct 21, 2002
74
CA
I am pulling a date from a dtabase and displaying it.However when it is displayed it must be displayed
as such 01/01/01.The key being the year portion can
only be 2 characters. It can not be 01/01/2001.The date can be entered into the database in any fashion as long as it is reconized as a date.Is there any way to format a date to just two characters in the year part not 4

Thanks
 
I think you will have to convert you date into a string and manipulate it, then you can display anything you like.

RIGHT(DatePart("yyyy",date),2)
BDC.
 
I pull the date out and store it in a variable strDate
so now strDate=04/03/2003
What is DatePart,
What is "yyyy",
andwhat is date in your function above
 
DatePart is a vbscript function "yyyy" and Date are the parameters I passed it.


If strDate is still of type Date then you can use the DatePart function to create a new string.

DateFormatted = DatePart("d",strDate) & "/"
DateFormatted = DateFormatted & DatePart("d",strDate) & "/"
DateFormatted = DateFormatted & RIGHT(DatePart("yyyy",strDate),2)

DateFormatted will now be 4/3/03

Further formatting will be required if you want 04/03/03

BDC.
 
I follow most of what you are saying but I dont quite understand what "d" and"yyyy" are.I assume they are strings but where areyou getting them from
 
The link will explain the format of the function

"d" gets the Day part of the date

"yyyy" gets the Year part of the date
BDC.
 
I've noticed you have posted in the javascript and ASP forums, which solution do you require?

thread216-491116 Javascript

thread333-491001 ASP
BDC.
 
Dim MyDate
MyDate = DateValue("3/5/2003") + TimeValue("4:14 AM")
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top