Anyway to force a 0 in the front of a single digit month in a date? 
Author Message
 Anyway to force a 0 in the front of a single digit month in a date?

Hi!

Is there a way to force a 0 in the front of a date whose month is only one
digit?

For example, currently I have an excel report and a browse that has a date
column that looks like this:

12/02/2002
  1/05/2003

I would like it to look like this:

12/02/2002
01/05/2003

Here is my current code for the column in the excel report:

      <td align="right"><%= rs.fields("ARODate").Value %> &nbsp;</td>

Thank you in advance.

Chuck



Wed, 21 Dec 2005 00:07:41 GMT  
 Anyway to force a 0 in the front of a single digit month in a date?

Quote:

> Hi!

> Is there a way to force a 0 in the front of a date whose month is
> only one digit?

> For example, currently I have an excel report and a browse that has a
> date column that looks like this:

> 12/02/2002
>   1/05/2003

> I would like it to look like this:

> 12/02/2002
> 01/05/2003

> Here is my current code for the column in the excel report:

>       <td align="right"><%= rs.fields("ARODate").Value %> &nbsp;</td>

<td align="right"><%= MyDateFormat(rs.fields("ARODate").Value) %>
&nbsp;</td>

where MyDateFormat() is a server side function you write to format and
return the date the way you want it...

--
Michael Harris
Microsoft.MVP.Scripting
Seattle WA US

Technet Script Center
http://www.microsoft.com/technet/scriptcenter/default.asp

Microsoft? Windows?2000 Scripting Guide
http://www.microsoft.com/technet/scriptcenter/scrguide/sagsas_overvie...



Wed, 21 Dec 2005 01:15:00 GMT  
 Anyway to force a 0 in the front of a single digit month in a date?
Hi Michael:

Any idea where I could find an example of a server side function formats a
date?

Thank you in advance

Chuck


Quote:

> > Hi!

> > Is there a way to force a 0 in the front of a date whose month is
> > only one digit?

> > For example, currently I have an excel report and a browse that has a
> > date column that looks like this:

> > 12/02/2002
> >   1/05/2003

> > I would like it to look like this:

> > 12/02/2002
> > 01/05/2003

> > Here is my current code for the column in the excel report:

> >       <td align="right"><%= rs.fields("ARODate").Value %> &nbsp;</td>

> <td align="right"><%= MyDateFormat(rs.fields("ARODate").Value) %>
> &nbsp;</td>

> where MyDateFormat() is a server side function you write to format and
> return the date the way you want it...

> --
> Michael Harris
> Microsoft.MVP.Scripting
> Seattle WA US

> Technet Script Center
> http://www.microsoft.com/technet/scriptcenter/default.asp

> Microsoft? Windows?2000 Scripting Guide
> http://www.microsoft.com/technet/scriptcenter/scrguide/sagsas_overvie...



Wed, 21 Dec 2005 03:42:59 GMT  
 Anyway to force a 0 in the front of a single digit month in a date?

Quote:

> Hi Michael:

> Any idea where I could find an example of a server side function
> formats a date?

Google Search: format date right year month day group:*.scripting
http://groups.google.com/groups?q=format%20date%20right%20year%20mont...

Function MyDateFormat(dt)
  MyDateFormat =  _
    right("0" & month(dt),2)  _
    & "/" & right("0" & day(dt),2) _
    & "/" & year(dt)
End Function

--
Michael Harris
Microsoft.MVP.Scripting
Seattle WA US

Technet Script Center
http://www.microsoft.com/technet/scriptcenter/default.asp

Microsoft? Windows?2000 Scripting Guide
http://www.microsoft.com/technet/scriptcenter/scrguide/sagsas_overvie...



Wed, 21 Dec 2005 06:18:01 GMT  
 Anyway to force a 0 in the front of a single digit month in a date?
Hi Michael!

Thank you for the function.

I have one other problem. I have another column called discountdate,
depending on the transaction type this column sometimes has no value. Is
there a way to modify the function so that if the value of the date that is
passed to the function is 0 that the returned value will be blank or N/A?

Thank you again.

Chuck



Quote:

> > Hi Michael:

> > Any idea where I could find an example of a server side function
> > formats a date?

> Google Search: format date right year month day group:*.scripting

http://groups.google.com/groups?q=format%20date%20right%20year%20mont...
Quote:

> Function MyDateFormat(dt)
>   MyDateFormat =  _
>     right("0" & month(dt),2)  _
>     & "/" & right("0" & day(dt),2) _
>     & "/" & year(dt)
> End Function

> --
> Michael Harris
> Microsoft.MVP.Scripting
> Seattle WA US

> Technet Script Center
> http://www.microsoft.com/technet/scriptcenter/default.asp

> Microsoft? Windows?2000 Scripting Guide
> http://www.microsoft.com/technet/scriptcenter/scrguide/sagsas_overvie...



Wed, 21 Dec 2005 10:30:59 GMT  
 Anyway to force a 0 in the front of a single digit month in a date?

Quote:

> Hi Michael!

> Thank you for the function.

> I have one other problem. I have another column called discountdate,
> depending on the transaction type this column sometimes has no value.
> Is
> there a way to modify the function so that if the value of the date
> that is
> passed to the function is 0 that the returned value will be blank or
> N/A?

Function MyDateFormat(dt)

  MyDateFormat = "N/A"

  If IsNull(dt) Then Exit Function

  If Not IsDate(dt) Then Exit Function

  MyDateFormat =  _
    right("0" & month(dt),2)  _
    & "/" & right("0" & day(dt),2) _
    & "/" & year(dt)

End Function

Quote:




>>> Hi Michael:

>>> Any idea where I could find an example of a server side function
>>> formats a date?

>> Google Search: format date right year month day group:*.scripting

http://groups.google.com/groups?q=format%20date%20right%20year%20mont...
Quote:

>> Function MyDateFormat(dt)
>>   MyDateFormat =  _
>>     right("0" & month(dt),2)  _
>>     & "/" & right("0" & day(dt),2) _
>>     & "/" & year(dt)
>> End Function

>> --
>> Michael Harris
>> Microsoft.MVP.Scripting
>> Seattle WA US

>> Technet Script Center
>> http://www.microsoft.com/technet/scriptcenter/default.asp

>> Microsoft? Windows?2000 Scripting Guide

http://www.microsoft.com/technet/scriptcenter/scrguide/sagsas_overvie...

--
Michael Harris
Microsoft.MVP.Scripting
Seattle WA US

Technet Script Center
http://www.microsoft.com/technet/scriptcenter/default.asp

Microsoft? Windows?2000 Scripting Guide
http://www.microsoft.com/technet/scriptcenter/scrguide/sagsas_overvie...



Wed, 21 Dec 2005 14:27:16 GMT  
 Anyway to force a 0 in the front of a single digit month in a date?
Hi Michael!

Thank you for the help.
Worked perfectly.

Chuck


Quote:

> > Hi Michael!

> > Thank you for the function.

> > I have one other problem. I have another column called discountdate,
> > depending on the transaction type this column sometimes has no value.
> > Is
> > there a way to modify the function so that if the value of the date
> > that is
> > passed to the function is 0 that the returned value will be blank or
> > N/A?

> Function MyDateFormat(dt)

>   MyDateFormat = "N/A"

>   If IsNull(dt) Then Exit Function

>   If Not IsDate(dt) Then Exit Function

>   MyDateFormat =  _
>     right("0" & month(dt),2)  _
>     & "/" & right("0" & day(dt),2) _
>     & "/" & year(dt)

> End Function




> >>> Hi Michael:

> >>> Any idea where I could find an example of a server side function
> >>> formats a date?

> >> Google Search: format date right year month day group:*.scripting

http://groups.google.com/groups?q=format%20date%20right%20year%20mont...

- Show quoted text -

Quote:

> >> Function MyDateFormat(dt)
> >>   MyDateFormat =  _
> >>     right("0" & month(dt),2)  _
> >>     & "/" & right("0" & day(dt),2) _
> >>     & "/" & year(dt)
> >> End Function

> >> --
> >> Michael Harris
> >> Microsoft.MVP.Scripting
> >> Seattle WA US

> >> Technet Script Center
> >> http://www.microsoft.com/technet/scriptcenter/default.asp

> >> Microsoft? Windows?2000 Scripting Guide

> http://www.microsoft.com/technet/scriptcenter/scrguide/sagsas_overvie...

> --
> Michael Harris
> Microsoft.MVP.Scripting
> Seattle WA US

> Technet Script Center
> http://www.microsoft.com/technet/scriptcenter/default.asp

> Microsoft? Windows?2000 Scripting Guide
> http://www.microsoft.com/technet/scriptcenter/scrguide/sagsas_overvie...



Thu, 22 Dec 2005 02:51:01 GMT  
 
 [ 7 post ] 

 Relevant Pages 

1. Microsoft Access Database Updates

2. dateformat and single digit months

3. how to force textbox to display dates using 4 digit years

4. WeekToDate, month to Date, Last Full Month

5. 4 digit date w date function

6. PROBLEM with DBedit

7. Obtaining single digits in textbox??

8. regular expression won't match single digit

9. forcing word to the front of the screen

10. Forcing an application to the front

11. How to force application to stay in front

12. Replacing digits[space] with digits[non-breaking space]

 

 
Powered by phpBB® Forum Software