Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
DotNet
acad.assignment.mngr
academic
adonet
aspnet
aspnet.announcements
aspnet.build.controls
aspnet.caching
aspnet.datagridcontrol
aspnet.mobile
aspnet.security
aspnet.webcontrols
aspnet.webservices
clr
compactframework
component_services
datatools
distributed_apps
drawing
faqs
framework
framework.wmi
general
internationalization
interop
languages.csharp
languages.jscript
languages.vb
languages.vb.controls
languages.vb.data
languages.vb.upgrade
languages.vc
languages.vc.libraries
myservices
odbcnet
performance
remoting
scripting
sdk
security
setup
vjsharp
vsa
webservi.enhancements
webservices
windowsforms
windowsforms.controls
winforms.databinding
winforms.designtime
xml
  
 
date: Tue, 7 Oct 2008 14:48:20 -0500,    group: microsoft.public.dotnet.framework.aspnet        back       


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?
date: Tue, 7 Oct 2008 14:48:20 -0500   author:   Seth Williams

Re: Get Date and format to 1st Day of month   
"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
date: Tue, 7 Oct 2008 21:10:19 +0100   author:   Mark Rae [MVP]

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?
date: Tue, 7 Oct 2008 17:12:21 -0300   author:   Gustavo Cantero

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us