![]() |
|
|
Welcome to the { mindfrost82.com } forums. You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today! If you have any problems with the registration process or your account login, please contact contact us. |
|
|||||||
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
|
|||
|
Get Date and format to 1st Day of month
I need to fill a textbox with a date that, based on the current day, is 2
months back - PLUS I need it to reflect the first day of the month so - I've got : Dim dNow As DateTime = DateTime.Now.ToShortDateString Dim NewDate As DateTime NewDate = dNow.AddMonths(-2) How do I make it so that the day portion of NewDate is always 1? |
|
|||
|
Re: Get Date and format to 1st Day of month
"Seth Williams" <sm@here.com> wrote in message
news:u%23p6pWLKJHA.3976@TK2MSFTNGP03.phx.gbl... > How do I make it so that the day portion of NewDate is always 1? Something like: Dim NewDate As DateTime = DateTime.Now.AddMonths(-2) NewDate = New DateTime(NewDate.Year, NewDate.Month, 1) Not 100% certain of the syntax, as I never go anywhere near VB.NET... -- Mark Rae ASP.NET MVP http://www.markrae.net |
|
|||
|
Re: Get Date and format to 1st Day of month
Seth:
Try with this: Dim dNow As DateTime = DateTime.Now Dim NewDate As DateTime NewDate = dNow.AddMonths(-2) NewDate = NewDate.AddDays((NewDate.Day - 1) * -1) Gustavo A. Cantero CEO - Scientia® Soluciones Informáticas MCP - MCSD - MCTS http://www.scientia.com.ar http://www.programandoamedianoche.com http://foro.scientia.com.ar -----Mensaje original----- De: Seth Williams [mailto:sm@here.com] Expuesto a las: Martes, 07 de Octubre de 2008 04:48 p.m. Expuesto en: microsoft.public.dotnet.framework.aspnet Conversación: Get Date and format to 1st Day of month Asunto: Get Date and format to 1st Day of month I need to fill a textbox with a date that, based on the current day, is 2 months back - PLUS I need it to reflect the first day of the month so - I've got : Dim dNow As DateTime = DateTime.Now.ToShortDateString Dim NewDate As DateTime NewDate = dNow.AddMonths(-2) How do I make it so that the day portion of NewDate is always 1? |
![]() |
|
| Thread Tools | Search this Thread |
| Display Modes | |
|
|