Date Function

1. Che
Senior Member
Join Date
Dec 1969
Posts
303

## Date Function

What do i need to use to write a date like 05/01/2003. Right now its writing like this 5/1/2003 but i need to write 05/01/2003. <BR><BR>Response.Write FormatDateTime(MyDate1, vbShortDate)

2. Senior Member
Join Date
Dec 1969
Posts
2,092

## RE: Date Function

Add 100 to your number then make use the Right() function like so: <BR><BR>Dim d_Day <BR>Dim d_Month <BR>Dim d_Year <BR><BR>d_Day = Right(Day(Now()) + 100, 2) <BR>d_Month = Right(Month(Now()) + 100, 2) <BR>d_Year = Right(Year(Now()) + 100, 2) <BR><BR>&#039;Then reconstruct the date using DateSerial() i think...double check on that :) <BR><BR>NOTE: I&#039;ve used the Now() function that returns the current date and time on the server, only for example purposes <BR><BR><BR>Hope this gives you an idea! <BR>Sincerely <BR><BR>Vlince <BR>

3. Senior Member
Join Date
Dec 1969
Posts
96,118

## No no...

...If you use DateSerial you are right back to a DATE value and not a string!<BR><BR>You started off find:<BR><BR>d_Day = Right(Day(Now()) + 100, 2) <BR>d_Month = Right(Month(Now()) + 100, 2) <BR>d_Year = Right(Year(Now()) + 100, 2) <BR><BR>but then all you need is:<BR> dateAsWanted = d_Month & "/" & d_Day & "/" & d_Year <BR><BR>Probably don&#039;t need to do anything with YEAR, though, since he said he wanted 4 digits anyway. So:<BR><BR> dateAsWanted = Right(Month(anyDate) + 100, 2) & "/" _<BR> & Right(Day(anyDate) + 100, 2) & "/" _<BR> & Year(anyDate)<BR><BR>

4. Che
Senior Member
Join Date
Dec 1969
Posts
303

## RE: No no...

Thank you so much for your quick responces. May be i did not give you enough information about my problem.<BR><BR>Here is my code:<BR>***************************************** *************<BR>****I am getting "From Date" and "To Date" from User Inputs****<BR><BR>&#060;%<BR>For MyDate = MyFrom to MyTo<BR>%&#062;<BR>&#060;tr&#062;<BR>&#060;td&#062 ;<BR>&#060;%<BR>If WeekDay(MyDate) &#060;&#062; vbSaturday And WeekDay(MyDate) &#060;&#062; vbSunday Then <BR>MyDate1 = FormatDateTime( MyDate, vbShortDate ) <BR>Response.Write MyDate1<BR>%&#062;<BR>&#060;/td&#062; <BR>********************************************** <BR><BR>MyDate1 is writing like this<BR>-----------------------<BR>5/1/2003<BR>5/2/2003<BR>.......<BR>5/31/2003<BR>--------------------------<BR>BUT I NEED LIKE THIS <BR>-------------------------<BR>05/01/2003<BR>05/02/2003<BR>.......<BR>05/31/2003

5. Senior Member
Join Date
Dec 1969
Posts
96,118

## Yes? What was wrong ...

...with the final answer I gave you?<BR><BR>Get rid of the FormatDateTime and use that code we gave you.<BR><BR>

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•