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?
"Seth Williams" 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
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?