|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Convert Now to a stringI have tried to make a string dim abc as string abc = format(now,"mm/dd/yyyy") or abc format$(now,"mm/dd/yyyy") but it doesn't work. I get: 28/25/2006 the day and year are ok, but the month is always wrong, the month is something different every time, Thanks in Advance, Laurence
Show quote
Hide quote
"Laurence" <Someth***@Something.com> wrote in message mm = Minutenews:uAYJPuQ4GHA.3644@TK2MSFTNGP03.phx.gbl... > In VS.2005 using VB.NET > > I have tried to make a string > > dim abc as string > abc = format(now,"mm/dd/yyyy") > or > abc format$(now,"mm/dd/yyyy") > > but it doesn't work. > > I get: 28/25/2006 > > the day and year are ok, but the month is always wrong, > the month is something different every time, > > Thanks in Advance, > > Laurence MM = Month Cheers. Use MM for month with leading zero.
mm is minute with leading zero. Laurence wrote: Show quoteHide quote > In VS.2005 using VB.NET > > I have tried to make a string > > dim abc as string > abc = format(now,"mm/dd/yyyy") > or > abc format$(now,"mm/dd/yyyy") > > but it doesn't work. > > I get: 28/25/2006 > > the day and year are ok, but the month is always wrong, > the month is something different every time, > > Thanks in Advance, > > Laurence -- Thank You,
Laurence wilson wrote: Show quoteHide quote > Use MM for month with leading zero. > mm is minute with leading zero. > > Laurence wrote: > >> In VS.2005 using VB.NET >> >> I have tried to make a string >> >> dim abc as string >> abc = format(now,"mm/dd/yyyy") >> or >> abc format$(now,"mm/dd/yyyy") >> >> but it doesn't work. >> >> I get: 28/25/2006 >> >> the day and year are ok, but the month is always wrong, >> the month is something different every time, >> >> Thanks in Advance, >> >> Laurence > > > Hello Laurence,
This is covered in the documentation. Press F1. -Boo Show quoteHide quote > In VS.2005 using VB.NET > > I have tried to make a string > > dim abc as string > abc = format(now,"mm/dd/yyyy") > or > abc format$(now,"mm/dd/yyyy") > but it doesn't work. > > I get: 28/25/2006 > > the day and year are ok, but the month is always wrong, the month is > something different every time, > > Thanks in Advance, > > Laurence > Laurence,
You are free to use the Format, but did you know that there was the overloaded ToString with the DateFormatProvider dim abc as string = now.ToString("d") I am not sure if it is d but that you can lookup on msdn. I hope this helps, Cor Show quoteHide quote "Laurence" <Someth***@Something.com> schreef in bericht news:uAYJPuQ4GHA.3644@TK2MSFTNGP03.phx.gbl... > In VS.2005 using VB.NET > > I have tried to make a string > > dim abc as string > abc = format(now,"mm/dd/yyyy") > or > abc format$(now,"mm/dd/yyyy") > > but it doesn't work. > > I get: 28/25/2006 > > the day and year are ok, but the month is always wrong, > the month is something different every time, > > Thanks in Advance, > > Laurence Another answer besides those provided:
Dim abc as string = DateTime.Now.ToShortDateString() |
|||||||||||||||||||||||