For Programmers: Free Programming Magazines  


Home > Archive > Visual Basic Syntax > March 2006 > formatting month value of date variable









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author formatting month value of date variable
NewbieDev

2006-03-07, 7:17 pm

Hi,

I would like to have the value of months that have only 1 digit (1-9) to be
01,02,etc. but the Month property of the date variable returns ony 1 digit.

Does anyone know how to do this?

Thanks,

ND

Bob Butler

2006-03-07, 7:17 pm

"NewbieDev" <NewbieDev@discussions.microsoft.com> wrote in message
news:C906A428-30A3-4EB7-A13E-5A569E84959D@microsoft.com
> Hi,
>
> I would like to have the value of months that have only 1 digit (1-9)
> to be 01,02,etc. but the Month property of the date variable returns
> ony 1 digit.
>
> Does anyone know how to do this?


convert to string

Right$("0" & CStr(m),2)

Format$(m,"00")


--
Reply to the group so all can participate
VB.Net: "Fool me once..."

NewbieDev

2006-03-07, 7:17 pm

Excellent, exactly what I needed in one line of code. Very elegant.

Thank you Bob

"Bob Butler" wrote:

> "NewbieDev" <NewbieDev@discussions.microsoft.com> wrote in message
> news:C906A428-30A3-4EB7-A13E-5A569E84959D@microsoft.com
>
> convert to string
>
> Right$("0" & CStr(m),2)
>
> Format$(m,"00")
>
>
> --
> Reply to the group so all can participate
> VB.Net: "Fool me once..."
>
>

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com